public static NoPlayerMediaPlayerCreator newInstance(Handler handler) { InternalCreator internalCreator = new InternalCreator(handler); return new NoPlayerMediaPlayerCreator(internalCreator); }
@Test public void whenCreatingMediaPlayer_thenInitialisesPlayer() { creator.createMediaPlayer(context); verify(player).initialise(); } }
/** * Builds a new {@link NoPlayer} instance. * * @param context The {@link Context} associated with the player. * @return a {@link NoPlayer} instance. * @throws UnableToCreatePlayerException thrown when the configuration is not supported and there is no way to recover. * @see NoPlayer */ public NoPlayer build(Context context) throws UnableToCreatePlayerException { Context applicationContext = context.getApplicationContext(); Handler handler = new Handler(Looper.getMainLooper()); ProvisionExecutorCreator provisionExecutorCreator = new ProvisionExecutorCreator(); DrmSessionCreatorFactory drmSessionCreatorFactory = new DrmSessionCreatorFactory( AndroidDeviceVersion.newInstance(), provisionExecutorCreator, handler ); NoPlayerCreator noPlayerCreator = new NoPlayerCreator( applicationContext, prioritizedPlayerTypes, NoPlayerExoPlayerCreator.newInstance(handler), NoPlayerMediaPlayerCreator.newInstance(handler), drmSessionCreatorFactory ); return noPlayerCreator.create(drmType, drmHandler, downgradeSecureDecoder); }
private NoPlayer createPlayerForType(PlayerType playerType, DrmType drmType, DrmHandler drmHandler, boolean downgradeSecureDecoder) { switch (playerType) { case MEDIA_PLAYER: return noPlayerMediaPlayerCreator.createMediaPlayer(context); case EXO_PLAYER: try { DrmSessionCreator drmSessionCreator = drmSessionCreatorFactory.createFor(drmType, drmHandler); return noPlayerExoPlayerCreator.createExoPlayer(context, drmSessionCreator, downgradeSecureDecoder); } catch (DrmSessionCreatorException exception) { throw new UnableToCreatePlayerException(exception); } default: throw UnableToCreatePlayerException.unhandledPlayerType(playerType); } } }
@Before public void setUp() throws DrmSessionCreatorException { given(drmSessionCreatorFactory.createFor(any(DrmType.class), any(DrmHandler.class))).willReturn(drmSessionCreator); given(noPlayerExoPlayerCreator.createExoPlayer(context, drmSessionCreator, USE_SECURE_CODEC)).willReturn(EXO_PLAYER); given(noPlayerMediaPlayerCreator.createMediaPlayer(context)).willReturn(MEDIA_PLAYER); noPlayerCreator = new NoPlayerCreator(context, prioritizedPlayerTypes(), noPlayerExoPlayerCreator, noPlayerMediaPlayerCreator, drmSessionCreatorFactory); }
@Before public void setUp() { creator = new NoPlayerMediaPlayerCreator(internalCreator); given(internalCreator.create(context)).willReturn(player); }