Here are the examples of the java api androidx.media2.test.service.RemoteMediaController.play() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
10 Examples
19
Source : MediaSessionCompatCallbackWithMediaControllerTest.java
with Apache License 2.0
from androidx
with Apache License 2.0
from androidx
@Test
public void play() throws Exception {
prepareLooper();
RemoteMediaController controller = createControllerAndWaitConnection();
mSessionCallback.reset(1);
controller.play();
replacedertTrue(mSessionCallback.await(TIME_OUT_MS));
replacedertEquals(1, mSessionCallback.mOnPlayCalledCount);
}
19
Source : MediaSessionCompatCallbackWithMediaControllerTest.java
with Apache License 2.0
from androidx
with Apache License 2.0
from androidx
@Test
public void setMediaUri_followedByPlayTwice_callsPlayFromUriAndPlay() throws Exception {
if (!MediaTestUtils.isClientToT()) {
return;
}
RemoteMediaController controller = createControllerAndWaitConnection();
mSessionCallback.reset(2);
controller.setMediaUri(Uri.parse("androidx://test"), /* extras= */
null);
controller.play();
controller.play();
replacedertTrue(mSessionCallback.await(TIMEOUT_MS));
replacedertTrue(mSessionCallback.mOnPlayFromUriCalled);
replacedertEquals(1, mSessionCallback.mOnPlayCalledCount);
}
19
Source : MediaSessionCompatCallbackWithMediaControllerTest.java
with Apache License 2.0
from androidx
with Apache License 2.0
from androidx
@Test
public void play() throws Exception {
RemoteMediaController controller = createControllerAndWaitConnection();
mSessionCallback.reset(1);
controller.play();
replacedertTrue(mSessionCallback.await(TIME_OUT_MS));
replacedertEquals(1, mSessionCallback.mOnPlayCalledCount);
}
17
Source : SessionPlayerTest.java
with Apache License 2.0
from androidx
with Apache License 2.0
from androidx
@Test
public void playByController() {
mController.play();
try {
replacedertTrue(mPlayer.mCountDownLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
} catch (InterruptedException e) {
fail(e.getMessage());
}
replacedertTrue(mPlayer.mPlayCalled);
}
16
Source : MediaSessionCompatCallbackWithMediaControllerTest.java
with Apache License 2.0
from androidx
with Apache License 2.0
from androidx
@Test
public void setMediaUri_followedByPlay_callsPlayFromMediaId() throws Exception {
if (!MediaTestUtils.isClientToT()) {
return;
}
String testMediaId = "anyMediaId";
Bundle testExtras = new Bundle();
testExtras.putString("testKey", "testValue");
RemoteMediaController controller = createControllerAndWaitConnection();
mSessionCallback.reset(1);
controller.setMediaUri(new Uri.Builder().scheme(MEDIA_URI_SCHEME).authority(MEDIA_URI_AUTHORITY).path(MEDIA_URI_PATH_SET_MEDIA_URI).appendQueryParameter(MEDIA_URI_QUERY_ID, testMediaId).build(), testExtras);
controller.play();
replacedertTrue(mSessionCallback.await(TIMEOUT_MS));
replacedertTrue(mSessionCallback.mOnPlayFromMediaIdCalled);
replacedertEquals(testMediaId, mSessionCallback.mMediaId);
replacedertTrue(TestUtils.equals(testExtras, mSessionCallback.mExtras));
replacedertNull(mSessionCallback.mQuery);
replacedertNull(mSessionCallback.mUri);
replacedertEquals(0, mSessionCallback.mOnPlayCalledCount);
}
16
Source : MediaSessionCompatCallbackWithMediaControllerTest.java
with Apache License 2.0
from androidx
with Apache License 2.0
from androidx
@Test
public void setMediaUri_followedByPlay_callsPlayFromSearch() throws Exception {
if (!MediaTestUtils.isClientToT()) {
return;
}
String testSearchQuery = "anyQuery";
Bundle testExtras = new Bundle();
testExtras.putString("testKey", "testValue");
RemoteMediaController controller = createControllerAndWaitConnection();
mSessionCallback.reset(1);
controller.setMediaUri(new Uri.Builder().scheme(MEDIA_URI_SCHEME).authority(MEDIA_URI_AUTHORITY).path(MEDIA_URI_PATH_SET_MEDIA_URI).appendQueryParameter(MEDIA_URI_QUERY_QUERY, testSearchQuery).build(), testExtras);
controller.play();
replacedertTrue(mSessionCallback.await(TIMEOUT_MS));
replacedertTrue(mSessionCallback.mOnPlayFromSearchCalled);
replacedertEquals(testSearchQuery, mSessionCallback.mQuery);
replacedertTrue(TestUtils.equals(testExtras, mSessionCallback.mExtras));
replacedertNull(mSessionCallback.mMediaId);
replacedertNull(mSessionCallback.mUri);
replacedertEquals(0, mSessionCallback.mOnPlayCalledCount);
}
15
Source : MediaSessionCompatCallbackWithMediaControllerTest.java
with Apache License 2.0
from androidx
with Apache License 2.0
from androidx
@Test
public void setMediaUri_followedByPlay_callsPlayFromUri() throws Exception {
if (!MediaTestUtils.isClientToT()) {
return;
}
Uri testMediaUri = Uri.parse("androidx://jetpack/test?query=android%20media");
Bundle testExtras = new Bundle();
testExtras.putString("testKey", "testValue");
RemoteMediaController controller = createControllerAndWaitConnection();
mSessionCallback.reset(1);
controller.setMediaUri(new Uri.Builder().scheme(MEDIA_URI_SCHEME).authority(MEDIA_URI_AUTHORITY).path(MEDIA_URI_PATH_SET_MEDIA_URI).appendQueryParameter(MEDIA_URI_QUERY_URI, testMediaUri.toString()).build(), testExtras);
controller.play();
replacedertTrue(mSessionCallback.await(TIMEOUT_MS));
replacedertTrue(mSessionCallback.mOnPlayFromUriCalled);
replacedertEquals(testMediaUri, mSessionCallback.mUri);
replacedertNull(mSessionCallback.mMediaId);
replacedertNull(mSessionCallback.mQuery);
replacedertEquals(0, mSessionCallback.mOnPlayCalledCount);
}
15
Source : MediaSessionCompatCallbackWithMediaControllerTest.java
with Apache License 2.0
from androidx
with Apache License 2.0
from androidx
@Test
public void setMediaUri_withoutFormattingFollowedByPlay_callsPlayFromUri() throws Exception {
if (!MediaTestUtils.isClientToT()) {
return;
}
Uri testMediaUri = Uri.parse("androidx://jetpack/test?query=android%20media");
Bundle testExtras = new Bundle();
testExtras.putString("testKey", "testValue");
RemoteMediaController controller = createControllerAndWaitConnection();
mSessionCallback.reset(1);
controller.setMediaUri(testMediaUri, testExtras);
controller.play();
replacedertTrue(mSessionCallback.await(TIMEOUT_MS));
replacedertTrue(mSessionCallback.mOnPlayFromUriCalled);
replacedertEquals(testMediaUri, mSessionCallback.mUri);
replacedertNull(mSessionCallback.mMediaId);
replacedertNull(mSessionCallback.mQuery);
replacedertEquals(0, mSessionCallback.mOnPlayCalledCount);
}
9
Source : MediaSessionCallbackTest.java
with Apache License 2.0
from androidx
with Apache License 2.0
from androidx
@Test
public void onCommandRequest() throws InterruptedException {
prepareLooper();
mPlayer = new MockPlayer(1);
final MockOnCommandCallback callback = new MockOnCommandCallback();
try (MediaSession session = new MediaSession.Builder(mContext, mPlayer).setSessionCallback(sHandlerExecutor, callback).setId("testOnCommandRequest").build()) {
RemoteMediaController controller = createRemoteController(session.getToken());
controller.pause();
replacedertFalse(mPlayer.mCountDownLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
replacedertFalse(mPlayer.mPauseCalled);
replacedertEquals(1, callback.commands.size());
replacedertEquals(SessionCommand.COMMAND_CODE_PLAYER_PAUSE, (long) callback.commands.get(0).getCommandCode());
controller.play();
replacedertTrue(mPlayer.mCountDownLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
replacedertTrue(mPlayer.mPlayCalled);
replacedertFalse(mPlayer.mPauseCalled);
replacedertEquals(2, callback.commands.size());
replacedertEquals(SessionCommand.COMMAND_CODE_PLAYER_PLAY, (long) callback.commands.get(1).getCommandCode());
}
}
9
Source : MediaSessionCallbackTest.java
with Apache License 2.0
from androidx
with Apache License 2.0
from androidx
@Test
public void onCommandRequest() throws InterruptedException {
mPlayer = new MockPlayer(1);
final MockOnCommandCallback callback = new MockOnCommandCallback();
try (MediaSession session = new MediaSession.Builder(mContext, mPlayer).setSessionCallback(sHandlerExecutor, callback).setId("testOnCommandRequest").build()) {
RemoteMediaController controller = createRemoteController(session.getToken());
controller.pause();
replacedertFalse(mPlayer.mCountDownLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
replacedertFalse(mPlayer.mPauseCalled);
replacedertEquals(1, callback.commands.size());
replacedertEquals(SessionCommand.COMMAND_CODE_PLAYER_PAUSE, (long) callback.commands.get(0).getCommandCode());
controller.play();
replacedertTrue(mPlayer.mCountDownLatch.await(TIMEOUT_MS, TimeUnit.MILLISECONDS));
replacedertTrue(mPlayer.mPlayCalled);
replacedertFalse(mPlayer.mPauseCalled);
replacedertEquals(2, callback.commands.size());
replacedertEquals(SessionCommand.COMMAND_CODE_PLAYER_PLAY, (long) callback.commands.get(1).getCommandCode());
}
}