mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-24 09:00:31 +00:00
mute intent send between main-bckgrnd-popup players
This commit is contained in:
parent
c4d5886059
commit
40f54aea53
@ -30,16 +30,16 @@ import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
|
||||
import com.google.android.exoplayer2.PlaybackParameters;
|
||||
import com.google.android.exoplayer2.Player;
|
||||
import com.google.android.exoplayer2.source.MediaSource;
|
||||
@ -341,7 +341,6 @@ public final class BackgroundPlayer extends Service {
|
||||
@Override
|
||||
public void handleIntent(final Intent intent) {
|
||||
super.handleIntent(intent);
|
||||
|
||||
resetNotification();
|
||||
if (bigNotRemoteView != null)
|
||||
bigNotRemoteView.setProgressBar(R.id.notificationProgressBar, 100, 0, false);
|
||||
@ -389,7 +388,6 @@ public final class BackgroundPlayer extends Service {
|
||||
@Override
|
||||
public void onPrepared(boolean playWhenReady) {
|
||||
super.onPrepared(playWhenReady);
|
||||
simpleExoPlayer.setVolume(1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -153,6 +153,8 @@ public abstract class BasePlayer implements
|
||||
public static final String START_PAUSED = "start_paused";
|
||||
@NonNull
|
||||
public static final String SELECT_ON_APPEND = "select_on_append";
|
||||
@NonNull
|
||||
public static final String IS_MUTED = "is_muted";
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
// Playback
|
||||
@ -275,6 +277,7 @@ public abstract class BasePlayer implements
|
||||
final float playbackPitch = intent.getFloatExtra(PLAYBACK_PITCH, getPlaybackPitch());
|
||||
final boolean playbackSkipSilence = intent.getBooleanExtra(PLAYBACK_SKIP_SILENCE,
|
||||
getPlaybackSkipSilence());
|
||||
final boolean isMuted = intent.getBooleanExtra(IS_MUTED, isMuted());
|
||||
|
||||
// seek to timestamp if stream is already playing
|
||||
if (simpleExoPlayer != null
|
||||
@ -283,7 +286,7 @@ public abstract class BasePlayer implements
|
||||
&& playQueue.getItem() != null
|
||||
&& queue.getItem().getUrl().equals(playQueue.getItem().getUrl())
|
||||
&& queue.getItem().getRecoveryPosition() != PlayQueueItem.RECOVERY_UNSET
|
||||
) {
|
||||
) {
|
||||
simpleExoPlayer.seekTo(playQueue.getIndex(), queue.getItem().getRecoveryPosition());
|
||||
return;
|
||||
|
||||
@ -293,7 +296,7 @@ public abstract class BasePlayer implements
|
||||
stateLoader = recordManager.loadStreamState(item)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doFinally(() -> initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
|
||||
/*playOnInit=*/true))
|
||||
/*playOnInit=*/true, isMuted))
|
||||
.subscribe(
|
||||
state -> queue.setRecovery(queue.getIndex(), state.getProgressTime()),
|
||||
error -> {
|
||||
@ -306,7 +309,7 @@ public abstract class BasePlayer implements
|
||||
}
|
||||
// Good to go...
|
||||
initPlayback(queue, repeatMode, playbackSpeed, playbackPitch, playbackSkipSilence,
|
||||
/*playOnInit=*/!intent.getBooleanExtra(START_PAUSED, false));
|
||||
/*playOnInit=*/!intent.getBooleanExtra(START_PAUSED, false), isMuted);
|
||||
}
|
||||
|
||||
protected void initPlayback(@NonNull final PlayQueue queue,
|
||||
@ -314,7 +317,8 @@ public abstract class BasePlayer implements
|
||||
final float playbackSpeed,
|
||||
final float playbackPitch,
|
||||
final boolean playbackSkipSilence,
|
||||
final boolean playOnReady) {
|
||||
final boolean playOnReady,
|
||||
final boolean isMuted) {
|
||||
destroyPlayer();
|
||||
initPlayer(playOnReady);
|
||||
setRepeatMode(repeatMode);
|
||||
@ -327,6 +331,8 @@ public abstract class BasePlayer implements
|
||||
|
||||
if (playQueueAdapter != null) playQueueAdapter.dispose();
|
||||
playQueueAdapter = new PlayQueueAdapter(context, playQueue);
|
||||
|
||||
if (isMuted) simpleExoPlayer.setVolume(0);
|
||||
}
|
||||
|
||||
public void destroyPlayer() {
|
||||
@ -536,12 +542,12 @@ public abstract class BasePlayer implements
|
||||
// Mute / Unmute
|
||||
//////////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
public void onMuteUnmuteButtonClicled(){
|
||||
public void onMuteUnmuteButtonClicled() {
|
||||
if (DEBUG) Log.d(TAG, "onMuteUnmuteButtonClicled() called");
|
||||
simpleExoPlayer.setVolume(isMuted() ? 1 : 0);
|
||||
}
|
||||
|
||||
public boolean isMuted(){
|
||||
public boolean isMuted() {
|
||||
return simpleExoPlayer.getVolume() == 0;
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||
playerImpl.setPlaybackQuality(playerState.getPlaybackQuality());
|
||||
playerImpl.initPlayback(playerState.getPlayQueue(), playerState.getRepeatMode(),
|
||||
playerState.getPlaybackSpeed(), playerState.getPlaybackPitch(),
|
||||
playerState.isPlaybackSkipSilence(), playerState.wasPlaying());
|
||||
playerState.isPlaybackSkipSilence(), playerState.wasPlaying(), playerImpl.isMuted());
|
||||
}
|
||||
}
|
||||
|
||||
@ -642,7 +642,8 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||
this.getPlaybackSkipSilence(),
|
||||
this.getPlaybackQuality(),
|
||||
false,
|
||||
!isPlaying()
|
||||
!isPlaying(),
|
||||
isMuted()
|
||||
);
|
||||
context.startService(intent);
|
||||
|
||||
@ -666,7 +667,8 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||
this.getPlaybackSkipSilence(),
|
||||
this.getPlaybackQuality(),
|
||||
false,
|
||||
!isPlaying()
|
||||
!isPlaying(),
|
||||
isMuted()
|
||||
);
|
||||
context.startService(intent);
|
||||
|
||||
|
@ -571,7 +571,8 @@ public final class PopupVideoPlayer extends Service {
|
||||
this.getPlaybackSkipSilence(),
|
||||
this.getPlaybackQuality(),
|
||||
false,
|
||||
!isPlaying()
|
||||
!isPlaying(),
|
||||
isMuted()
|
||||
);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
|
@ -197,7 +197,8 @@ public abstract class ServicePlayerActivity extends AppCompatActivity
|
||||
this.player.getPlaybackSkipSilence(),
|
||||
null,
|
||||
false,
|
||||
false
|
||||
false,
|
||||
this.player.isMuted()
|
||||
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
.putExtra(BasePlayer.START_PAUSED, !this.player.isPlaying());
|
||||
}
|
||||
|
@ -110,13 +110,15 @@ public class NavigationHelper {
|
||||
final boolean playbackSkipSilence,
|
||||
@Nullable final String playbackQuality,
|
||||
final boolean resumePlayback,
|
||||
final boolean startPaused) {
|
||||
final boolean startPaused,
|
||||
final boolean isMuted) {
|
||||
return getPlayerIntent(context, targetClazz, playQueue, playbackQuality, resumePlayback)
|
||||
.putExtra(BasePlayer.REPEAT_MODE, repeatMode)
|
||||
.putExtra(BasePlayer.PLAYBACK_SPEED, playbackSpeed)
|
||||
.putExtra(BasePlayer.PLAYBACK_PITCH, playbackPitch)
|
||||
.putExtra(BasePlayer.PLAYBACK_SKIP_SILENCE, playbackSkipSilence)
|
||||
.putExtra(BasePlayer.START_PAUSED, startPaused);
|
||||
.putExtra(BasePlayer.START_PAUSED, startPaused)
|
||||
.putExtra(BasePlayer.IS_MUTED, isMuted);
|
||||
}
|
||||
|
||||
public static void playOnMainPlayer(final Context context, final PlayQueue queue, final boolean resumePlayback) {
|
||||
|
Loading…
Reference in New Issue
Block a user