72 Commits

Author SHA1 Message Date
jaewan
4782e227eb Rename androidX MediaItem to media2 MediaItem
In AndroidX, both media1 and media2 have MediaItem classes,
so change the naming to remove ambiguity.

PiperOrigin-RevId: 327261260
2020-08-21 12:49:43 +01:00
jaewan
e6d36e8b92 Add SessionPlayerConnector ctor that use DefaultMediaItemConverter
PiperOrigin-RevId: 327258863
2020-08-21 12:49:34 +01:00
jaewan
b39721f4b5 Make ExoPlayer as the trusted source of playlist
Playlist can now be obtained directly from Timeline windows
in any state. So make ExoPlayer as the trusted source of
playlist, instead of SessionPlayerConnector.

PlayerWrapper still need to keep the list of media items.
It's used to detect whether the Timeline change is caused by
changes in media items or not, and only notify
SessionPlayer.PlayerCallback#onPlaylistChanged() only when
the playlist is really changed.

PiperOrigin-RevId: 327231820
2020-08-21 12:49:25 +01:00
jaewan
be98509e03 Workaround test failure with stable release of media2.session
MediaSession requires prepared Looper in 1.0.3-stable release,
which is the latest stable release for now.

The requirement would be removed in 1.1.0-stable, but workaround
is needed meanwhile.

PiperOrigin-RevId: 327220042
2020-08-21 12:48:57 +01:00
olly
49bf83a169 Media2: Remove MediaSourceFactory + DataSourceCallback
- Applications should generally use DefaultMediaSourceFactory,
  or their own custom implementation if they need one. Having the
  media2 extension implement its own version directly doesn't seem
  that useful.
- Remove support for CallbackMediaItem. This type of MediaItem
  doesn't go cross-process, and it seems like there would never
  be a use case where an app would need to generate one locally.
  If an app needs to provide data from a custom source, it should
  hook into ExoPlayer's way of doing this (i.e., use a UriMediaItem
  with a custom scheme, and inject a custom DataSource that can
  handle this scheme).

PiperOrigin-RevId: 326914465
2020-08-17 16:13:34 +01:00
olly
42cf213aea Media2 tests: Simplify code
- Use ExoPlayer DataSource instrumentation to intercept reads
- Use ExoPlayer Resource URIs
- Use ExoPlayer DefaultMediaSourceFactory

PiperOrigin-RevId: 326912324
2020-08-17 16:13:25 +01:00
jaewan
c2ac33af1b Clean up PlayerWrapper exception log
PlayerWrapper throws Exception if getters is called in the
STATE_IDLE. In that case, log may print 50+ lines of stack
traces. It's verbose and can be considered as serious issue.

This CL include folloing changes
  - Change to use ExoPlayer's log class
  - Adjust log level, because it would be consumed by caller
  - Leave log when the debug flag is turned on.

Another CL will remove exceptions between PlayerWrapper and
and SessionPlayerConnector, not to use Exception for ordinary
control flow as the Effective Java suggests.

PiperOrigin-RevId: 326614559
2020-08-17 16:12:48 +01:00
olly
cdf07f1745 Media2 tests: Clean up assets
Even after this change, it's unclear to me why we need so many
assets for these tests. Just doing a minimal pass for now though!

PiperOrigin-RevId: 326613941
2020-08-17 16:12:39 +01:00
jaewan
e6bf7bd0ff Migrate to use Player's top level playlist API
Being specific, this includes following changes
  - Remove PlaylistManager and TimelinePlaylistManager
    and use Player's playlist API directly.
  - Replace ConcatenatingMediaSource uses with
    ExoPlayer MediaItem.
  - Replace PlaybackPreparer uses with Player#prepare()
  - Add MediaItemConverter for developers to customize
    converting AndroidX MediaItems to ExoPlayer MediaItems
    and vice-versa.
  - Add DefaultMediaItemConverter for providing default
    implementation of both MediaItemConverter
    and MediaSourceFactory.

Note that removing PlaylistManager loses the ability
to suppress individual playlist API. But decided to remove
for simpler API set. The feature can be added back later
via explicit request.

PiperOrigin-RevId: 326463492
2020-08-17 16:12:21 +01:00
jaewan
f2866a4942 Notify current media item to legacy controllers
This is the workaround for b/159147455.

The issue will be fixed in media2-session 1.1.0-stable, but we'd
better to have workaround until it's ready.

PiperOrigin-RevId: 325434543
2020-08-07 19:04:56 +01:00
gyumin
6e11d32092 Use static import for TimeUnit
PiperOrigin-RevId: 324941042
2020-08-07 19:01:07 +01:00
jaewan
9743e47f1f Remove unncessary TODOs
PiperOrigin-RevId: 323286632
2020-07-27 23:59:07 +01:00
ibaker
84e13e3bd0 Replace media2 SettableFuture with Guava version
PiperOrigin-RevId: 322530026
2020-07-24 10:44:11 +01:00
olly
0cd15d9158 Proactively check listener arguments are non-null
PiperOrigin-RevId: 322143359
2020-07-24 10:40:24 +01:00
ibaker
b755df1338 Update PlayerWrapper methods to return void where possible
Suggested during the review of 437d1b6e9a

This keeps the Runnable -> Callable<Boolean> conversion encapsulated
inside SessionPlayerConnector which makes it clearer why it's needed.

PiperOrigin-RevId: 321553744
2020-07-24 10:37:32 +01:00
ibaker
e682f53b3c Migrate overrides of deprecated onPlaybackParametersChanged
This method has been replaced by onPlaybackSpeedChanged

PiperOrigin-RevId: 321369921
2020-07-24 10:36:02 +01:00
ibaker
437d1b6e9a Migrate usages of deprecated Player#set/getPlaybackParameters()
PiperOrigin-RevId: 321166822
2020-07-24 10:33:36 +01:00
ibaker
f83d478cc3 Migrate uses of prepare(MediaSource) to setMediaSource() & prepare()
PiperOrigin-RevId: 321147910
2020-07-24 10:31:57 +01:00
ibaker
e9a8335381 Migrate callers to pass MediaItem to createMediaSource()
createMediaSource(Uri) is deprecated.

PiperOrigin-RevId: 321121383
2020-07-24 10:31:22 +01:00
ibaker
23d680a4b4 Suppress deprecation warnings in deprecated places
PiperOrigin-RevId: 320970814
2020-07-24 10:30:53 +01:00
olly
f205539616 Use lambdas where possible
PiperOrigin-RevId: 320960833
2020-07-13 17:00:44 +01:00
jaewan
02f8cdf1d9 Release media2 extension
PiperOrigin-RevId: 320351394
2020-07-09 08:28:14 +00:00