From ebd9395495a3b7cf4424c392a4573aab04b00f51 Mon Sep 17 00:00:00 2001 From: sahar Date: Wed, 9 Feb 2022 19:23:28 +0100 Subject: [PATCH] Production Code of UsbPlayer.prev() implemented --- src/main/java/device/usbPlayer/UsbPlayer.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 75f6a21..0a6e75d 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -118,7 +118,12 @@ public class UsbPlayer implements Device { @Override public void prev() { - + int currentIdex = Playlist.indexOf(playTrack); + int nextIndex = Playlist.size() - 1; + if (currentIdex != 0) { + nextIndex = (currentIdex - 1); + } + playTrack = Playlist.get(nextIndex); } @Override