Search in sources :

Example 1 with ForwardingPlayer

use of com.google.android.exoplayer2.ForwardingPlayer in project ExoPlayer by google.

the class SessionPlayerConnectorTest method play_withForwardingPlayer_isSkipped.

@Test
@LargeTest
public void play_withForwardingPlayer_isSkipped() throws Exception {
    if (Looper.myLooper() == null) {
        Looper.prepare();
    }
    Player forwardingPlayer = null;
    SessionPlayerConnector playerConnector = null;
    try {
        Player exoPlayer = new ExoPlayer.Builder(context).setLooper(Looper.myLooper()).build();
        forwardingPlayer = new ForwardingPlayer(exoPlayer) {

            @Override
            public boolean isCommandAvailable(int command) {
                if (command == COMMAND_PLAY_PAUSE) {
                    return false;
                }
                return super.isCommandAvailable(command);
            }

            @Override
            public Commands getAvailableCommands() {
                return super.getAvailableCommands().buildUpon().remove(COMMAND_PLAY_PAUSE).build();
            }
        };
        playerConnector = new SessionPlayerConnector(forwardingPlayer);
        assertPlayerResult(playerConnector.play(), RESULT_INFO_SKIPPED);
    } finally {
        if (playerConnector != null) {
            playerConnector.close();
        }
        if (forwardingPlayer != null) {
            forwardingPlayer.release();
        }
    }
}
Also used : Player(com.google.android.exoplayer2.Player) ExoPlayer(com.google.android.exoplayer2.ExoPlayer) SessionPlayer(androidx.media2.common.SessionPlayer) ForwardingPlayer(com.google.android.exoplayer2.ForwardingPlayer) ForwardingPlayer(com.google.android.exoplayer2.ForwardingPlayer) MediumTest(androidx.test.filters.MediumTest) LargeTest(androidx.test.filters.LargeTest) SmallTest(androidx.test.filters.SmallTest) Test(org.junit.Test) LargeTest(androidx.test.filters.LargeTest)

Aggregations

SessionPlayer (androidx.media2.common.SessionPlayer)1 LargeTest (androidx.test.filters.LargeTest)1 MediumTest (androidx.test.filters.MediumTest)1 SmallTest (androidx.test.filters.SmallTest)1 ExoPlayer (com.google.android.exoplayer2.ExoPlayer)1 ForwardingPlayer (com.google.android.exoplayer2.ForwardingPlayer)1 Player (com.google.android.exoplayer2.Player)1 Test (org.junit.Test)1