diff --git a/app/src/main/java/org/xbmc/kore/Settings.java b/app/src/main/java/org/xbmc/kore/Settings.java index 6fa971a..16914ec 100644 --- a/app/src/main/java/org/xbmc/kore/Settings.java +++ b/app/src/main/java/org/xbmc/kore/Settings.java @@ -81,6 +81,10 @@ public class Settings { public static final String KEY_PREF_SHOW_NOW_PLAYING_PANEL = "pref_show_nowplayingpanel"; public static final boolean DEFAULT_PREF_SHOW_NOW_PLAYING_PANEL = true; + // Seek mode + public static final String KEY_PREF_NOTIFICATION_SEEK_JUMP = "pref_notification_seek_jump"; + public static final boolean DEFAULT_PREF_NOTIFICATION_SEEK_JUMP = false; + // Pause during calls public static final String KEY_PREF_PAUSE_DURING_CALLS = "pref_pause_during_calls"; public static final boolean DEFAULT_PREF_PAUSE_DURING_CALLS = false; diff --git a/app/src/main/java/org/xbmc/kore/jsonrpc/method/Player.java b/app/src/main/java/org/xbmc/kore/jsonrpc/method/Player.java index 62a8459..8d957fc 100644 --- a/app/src/main/java/org/xbmc/kore/jsonrpc/method/Player.java +++ b/app/src/main/java/org/xbmc/kore/jsonrpc/method/Player.java @@ -241,6 +241,12 @@ public class Player { public static final class Seek extends ApiMethod { public final static String METHOD_NAME = "Player.Seek"; + /** + * Seek constants + */ + public static final String BACKWARD = "smallbackward"; + public static final String FORWARD = "smallforward"; + /** * Seek through the playing item (by time) * @param playerId Player id for which to stop playback @@ -263,6 +269,17 @@ public class Player { addParameterToRequest("value", value); } + /** + * Seek through the playing item (by step) + * @param playerId Player id for which to stop playback + * @param value step (smallbackward/smallforward) + */ + public Seek(int playerId, String value) { + super(); + addParameterToRequest("playerid", playerId); + addParameterToRequest("value", value); + } + @Override public String getMethodName() { return METHOD_NAME; } diff --git a/app/src/main/java/org/xbmc/kore/service/IntentActionsService.java b/app/src/main/java/org/xbmc/kore/service/IntentActionsService.java index f336959..220de27 100644 --- a/app/src/main/java/org/xbmc/kore/service/IntentActionsService.java +++ b/app/src/main/java/org/xbmc/kore/service/IntentActionsService.java @@ -38,7 +38,9 @@ public class IntentActionsService extends Service { ACTION_REWIND = "rewind", ACTION_FAST_FORWARD = "fast_forward", ACTION_PREVIOUS = "previous", - ACTION_NEXT = "next"; + ACTION_NEXT = "next", + ACTION_JUMP_BACKWARD = "jump_backward", + ACTION_JUMP_FORWARD = "jump_forward"; @Override public void onCreate() { } @@ -79,6 +81,16 @@ public class IntentActionsService extends Service { new Player.GoTo(playerId, Player.GoTo.NEXT), null, null); break; + case ACTION_JUMP_BACKWARD: + hostConnection.execute( + new Player.Seek(playerId, Player.Seek.BACKWARD), + null, null); + break; + case ACTION_JUMP_FORWARD: + hostConnection.execute( + new Player.Seek(playerId, Player.Seek.FORWARD), + null, null); + break; } } diff --git a/app/src/main/java/org/xbmc/kore/service/NotificationObserver.java b/app/src/main/java/org/xbmc/kore/service/NotificationObserver.java index 9e73381..522d893 100644 --- a/app/src/main/java/org/xbmc/kore/service/NotificationObserver.java +++ b/app/src/main/java/org/xbmc/kore/service/NotificationObserver.java @@ -27,6 +27,7 @@ import android.content.res.Resources; import android.graphics.Bitmap; import android.graphics.drawable.Drawable; import android.os.Build; +import android.preference.PreferenceManager; import android.support.v4.app.NotificationCompat; import android.support.v4.app.TaskStackBuilder; import android.view.View; @@ -35,6 +36,7 @@ import android.widget.RemoteViews; import com.squareup.picasso.Picasso; import com.squareup.picasso.Target; import org.xbmc.kore.R; +import org.xbmc.kore.Settings; import org.xbmc.kore.host.HostConnectionObserver; import org.xbmc.kore.host.HostManager; import org.xbmc.kore.jsonrpc.notification.Player; @@ -227,14 +229,22 @@ public class NotificationObserver break; } - // Create the actions, depending on the type of media + // Create the actions, depending on the type of media and the user's preference PendingIntent rewindPendingIntent, ffPendingIntent, playPausePendingIntent; playPausePendingIntent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_PLAY_PAUSE); + boolean useSeekJump = PreferenceManager + .getDefaultSharedPreferences(this.mService) + .getBoolean(Settings.KEY_PREF_NOTIFICATION_SEEK_JUMP, Settings.DEFAULT_PREF_NOTIFICATION_SEEK_JUMP); if (getItemResult.type.equals(ListType.ItemsAll.TYPE_SONG)) { rewindPendingIntent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_PREVIOUS); rewindIcon = R.drawable.ic_skip_previous_white_24dp; ffPendingIntent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_NEXT); ffIcon = R.drawable.ic_skip_next_white_24dp; + } else if (useSeekJump) { + rewindPendingIntent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_JUMP_BACKWARD); + rewindIcon = R.drawable.ic_chevron_left_white_24dp; + ffPendingIntent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_JUMP_FORWARD); + ffIcon = R.drawable.ic_chevron_right_white_24dp; } else { rewindPendingIntent = buildActionPendingIntent(getActivePlayerResult.playerid, IntentActionsService.ACTION_REWIND); rewindIcon = R.drawable.ic_fast_rewind_white_24dp; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 1a19287..775ecc9 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -349,6 +349,9 @@ Show notification while playing Show now playing panel while playing Displays an expandable panel at the bottom of the screen when media is playing + Use steps for seeking + Change playback speed when seeking from notification + Use skip steps when seeking from notification Pause during phone call Use device volume keys Vibrate on touch diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 66b069a..13e688b 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -64,6 +64,14 @@ android:title="@string/show_notification" android:defaultValue="false"/> + +