c# - Mediaelement Playlist repeat how to? -


i can't find solution how reset index when last file has been opened. have mediaelement reads images listbox , when last image has been played want restart. repeatable mediaelement playlist. please help, need one.

    dictionary<string, string> listbox1dict = new dictionary<string, string>();     public static list<string> images = new list<string> { ".jpg", ".jpe", ".bmp", ".gif", ".png" }; // bildtyper som stöds     public static list<string> movies = new list<string> { ".wmv", ".wav", ".swf", ".mp4", ".mpg", ".avi" }; // filmtyper som stöds     list<string> paths = new list<string>();     dispatchertimer dispatchertimer = new dispatchertimer();     dispatchertimer nextimagetimer = new dispatchertimer();     int x = 20; //ställa in antal sekunder per bild     private int currentsongindex = -1;      private void dispatchertimer_tick(object sender, eventargs e)     {             shownextimage();     }     private void dispatch()     {         dispatchertimer.tick += new eventhandler(dispatchertimer_tick);         dispatchertimer.interval = new timespan(0, 0, 0, x);     }      private void shownextimage()     {         if (currentsongindex == -1)         {             currentsongindex = listbox1.selectedindex;         }         currentsongindex++;          var selected = listbox1.items[currentsongindex];         string s = selected.tostring();         if (listbox1dict.containskey(s))         {              if (images.contains(system.io.path.getextension(s).toupperinvariant()))             {                  if (currentsongindex < listbox1.items.count)                 {                     mediaelement1.visibility = visibility.visible;                     searchbtn.visibility = visibility.hidden;                     listbox1.visibility = visibility.hidden;                     filenametextbox.visibility = visibility.hidden;                     mediaelement1.source = new uri(listbox1dict[s]);                     mediaelement1.width = system.windows.systemparameters.primaryscreenwidth;                     mediaelement1.height = system.windows.systemparameters.primaryscreenheight;                     this.background = new solidcolorbrush(colors.black);                     this.windowstyle = windowstyle.none;                     this.windowstate = windowstate.maximized;                     mediaelement1.stretchdirection = stretchdirection.both;                     mediaelement1.stretch = stretch.fill;                     dispatchertimer.start();                  }             }             else if (movies.contains(system.io.path.getextension(s).toupperinvariant()))             {                 if (currentsongindex < listbox1.items.count)                 {                     dispatchertimer.stop();                     mediaelement1.visibility = visibility.visible;                     listbox1.visibility = visibility.hidden;                     filenametextbox.visibility = visibility.hidden;                     mediaelement1.source = new uri(listbox1dict[s]);                     mediaelement1.width = system.windows.systemparameters.primaryscreenwidth;                     mediaelement1.height = system.windows.systemparameters.primaryscreenheight;                     this.background = new solidcolorbrush(colors.black);                     this.windowstyle = windowstyle.none;                     this.windowstate = windowstate.maximized;                     mediaelement1.stretchdirection = stretchdirection.both;                     mediaelement1.stretch = stretch.fill;                 }             }         }     } 

cant like:

private void shownextimage() {     if (currentsongindex == -1)     {         currentsongindex = listbox1.selectedindex;     }     if (currentsongindex == listbox1.items.count)     {         currentsongindex = 0;     }     currentsongindex++;     .... } 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -