Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7bc38aa9 authored by wjiang's avatar wjiang Committed by cretin45
Browse files

Gallery2: don't pause background music perminently

Gallery app requests transient audio focus twice and explicitly pauses
background music playback. To allow music resume after movie playback
exists, remove redundant audio focus request and pause broadcast.

CRs-Fixed: 695669
Change-Id: I46b88defc887d3e5b5c97acdc4f5a0a11d486a76
parent 34f0f73d
Loading
Loading
Loading
Loading
+0 −12
Original line number Diff line number Diff line
@@ -89,11 +89,6 @@ public class MoviePlayer implements
    private static final int KEYCODE_MEDIA_PLAY = 126;
    private static final int KEYCODE_MEDIA_PAUSE = 127;

    // Copied from MediaPlaybackService in the Music Player app.
    private static final String SERVICECMD = "com.android.music.musicservicecommand";
    private static final String CMDNAME = "command";
    private static final String CMDPAUSE = "pause";

    private static final String KEY_VIDEO_CAN_SEEK = "video_can_seek";
    private static final String KEY_VIDEO_CAN_PAUSE = "video_can_pause";
    private static final String KEY_VIDEO_LAST_DURATION = "video_last_duration";
@@ -297,10 +292,6 @@ public class MoviePlayer implements
        filter.addAction(Intent.ACTION_SHUTDOWN);
        mContext.registerReceiver(mReceiver, filter);

        Intent i = new Intent(SERVICECMD);
        i.putExtra(CMDNAME, CMDPAUSE);
        movieActivity.sendBroadcast(i);

        if (savedInstance != null) { // this is a resumed activity
            mVideoPosition = savedInstance.getInt(KEY_VIDEO_POSITION, 0);
            mResumeableTime = savedInstance.getLong(KEY_RESUMEABLE_TIME, Long.MAX_VALUE);
@@ -608,9 +599,6 @@ public class MoviePlayer implements
    }

    private void doStartVideo(boolean enableFasten, int position, int duration) {
        ((AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE)).requestAudioFocus(
                null, AudioManager.STREAM_MUSIC,
                AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
        doStartVideo(enableFasten, position, duration, true);
    }

+1 −5
Original line number Diff line number Diff line
@@ -455,11 +455,7 @@ public class CodeauroraVideoView extends SurfaceView implements MediaPlayerContr
            // not ready for playback just yet, will try again later
            return;
        }
        // Tell the music playback service to pause
        // TODO: these constants need to be published somewhere in the framework.
        Intent i = new Intent("com.android.music.musicservicecommand");
        i.putExtra("command", "pause");
        mContext.sendBroadcast(i);

        // we shouldn't clear the target state, because somebody might have
        // called start() previously
        release(false);