Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
Expand Down Expand Up @@ -66,7 +65,7 @@ public void handleMessage(final Message msg) {
command = MusicService.ACTION_SKIP;
break;
case 3:
command = MusicService.ACTION_REWIND;
command = MusicService.ACTION_PREVIOUS;
break;
default:
command = null;
Expand Down Expand Up @@ -118,14 +117,20 @@ public static boolean handleIntent(final Context context, final Intent intent) {
command = MusicService.ACTION_SKIP;
break;
case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
command = MusicService.ACTION_REWIND;
command = MusicService.ACTION_PREVIOUS;
break;
case KeyEvent.KEYCODE_MEDIA_PAUSE:
command = MusicService.ACTION_PAUSE;
break;
case KeyEvent.KEYCODE_MEDIA_PLAY:
command = MusicService.ACTION_PLAY;
break;
case KeyEvent.KEYCODE_MEDIA_REWIND:
command = MusicService.ACTION_REWIND;
break;
case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD:
command = MusicService.ACTION_FASTFORWARD;
break;
}
if (command != null) {
if (action == KeyEvent.ACTION_DOWN) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import android.support.v4.media.MediaMetadataCompat;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import android.util.Log;
import android.widget.Toast;

import androidx.annotation.NonNull;
Expand Down Expand Up @@ -64,6 +65,7 @@
import com.kabouzeid.gramophone.util.Util;

import java.lang.ref.WeakReference;
import java.time.Clock;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
Expand All @@ -82,7 +84,10 @@ public class MusicService extends Service implements SharedPreferences.OnSharedP
public static final String ACTION_PAUSE = PHONOGRAPH_PACKAGE_NAME + ".pause";
public static final String ACTION_STOP = PHONOGRAPH_PACKAGE_NAME + ".stop";
public static final String ACTION_SKIP = PHONOGRAPH_PACKAGE_NAME + ".skip";
public static final String ACTION_PREVIOUS = PHONOGRAPH_PACKAGE_NAME + ".previous";
public static final String ACTION_FASTFORWARD = PHONOGRAPH_PACKAGE_NAME + ".fastforward";
public static final String ACTION_REWIND = PHONOGRAPH_PACKAGE_NAME + ".rewind";

public static final String ACTION_QUIT = PHONOGRAPH_PACKAGE_NAME + ".quitservice";
public static final String ACTION_PENDING_QUIT = PHONOGRAPH_PACKAGE_NAME + ".pendingquitservice";
public static final String INTENT_EXTRA_PLAYLIST = PHONOGRAPH_PACKAGE_NAME + "intentextra.playlist";
Expand Down Expand Up @@ -340,12 +345,18 @@ public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
Toast.makeText(getApplicationContext(), R.string.playlist_is_empty, Toast.LENGTH_LONG).show();
}
break;
case ACTION_REWIND:
case ACTION_PREVIOUS:
back(true);
break;
case ACTION_SKIP:
playNextSong(true);
break;
case ACTION_REWIND:
seek(getSongProgressMillis() - 10000);
break;
case ACTION_FASTFORWARD:
seek(getSongProgressMillis() + 10000);
break;
case ACTION_STOP:
case ACTION_QUIT:
pendingQuit = false;
Expand Down