Add setting to use skip steps instead of seeking (#152)

closes #147
This commit is contained in:
Adrian 2018-04-15 16:39:06 +02:00 committed by Synced Synapse
parent 93d4d37f1c
commit 7c18df20cf
6 changed files with 56 additions and 2 deletions

View File

@ -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;

View File

@ -241,6 +241,12 @@ public class Player {
public static final class Seek extends ApiMethod<PlayerType.SeekReturnType> {
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; }

View File

@ -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;
}
}

View File

@ -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;

View File

@ -349,6 +349,9 @@
<string name="show_notification">Show notification while playing</string>
<string name="show_now_playing_panel">Show now playing panel while playing</string>
<string name="show_now_playing_panel_summary">Displays an expandable panel at the bottom of the screen when media is playing</string>
<string name="notification_seek_jump">Use steps for seeking</string>
<string name="notification_seek_jump_speed">Change playback speed when seeking from notification</string>
<string name="notification_seek_jump_step">Use skip steps when seeking from notification</string>
<string name="pause_during_calls">Pause during phone call</string>
<string name="use_hardware_volume_keys">Use device volume keys</string>
<string name="vibrate_on_remote">Vibrate on touch</string>

View File

@ -64,6 +64,14 @@
android:title="@string/show_notification"
android:defaultValue="false"/>
<SwitchPreference
android:key="pref_notification_seek_jump"
android:dependency="pref_show_notification"
android:title="@string/notification_seek_jump"
android:summaryOff="@string/notification_seek_jump_speed"
android:summaryOn="@string/notification_seek_jump_step"
android:defaultValue="false"/>
<SwitchPreferenceCompat
android:key="pref_pause_during_calls"
android:title="@string/pause_during_calls"