handle btn1 in sidebar, switchable tracks
[uwplayer.git] / application / playlist.c
index 06172c3..80d335b 100644 (file)
@@ -54,13 +54,18 @@ void PlayListPlayNext(MainWindow *win, bool force) {
         current = 0;
     }
     
-    win->playlist.current_track = current;
-    
-    UcxList *fileElm = ucx_list_get(tracks, current);
-    if(!fileElm) {
-        return;
+    PlayListPlayTrack(win, current);
+}
+
+void PlayListPlayTrack(MainWindow *win, int i) {
+    UcxList *tracks = win->playlist.tracks;
+    if(i < ucx_list_size(tracks)) {
+        win->playlist.current_track = i;
+        UcxList *fileElm = ucx_list_get(tracks, i);
+        if(fileElm) {
+            win->file = fileElm->data;
+            PlayerOpenFile(win);
+            win->playlist.current_track = i;
+        }
     }
-    win->file = fileElm->data;
-    
-    PlayerOpenFile(win);
 }