这是indexloc提供的服务,不要输入任何密码
Skip to content

Using a MediaLibrarySession with multiple Players and switching based on content type #2623

@adambeers

Description

@adambeers

I have a DelegatingPlayer which implements the entire Player interface and contains 3 Players: ExoPlayer, CastPlayer and TextToSpeechPlayer(which extends the SimpleBasePlayer). When the user loads a list, which could contain MP3 and text-to-speech items. Currently, we can only use one player, so the user will get either ExoPlayer or TextToSpeechPlayer and can't play all items since the items are Player specific.

The real question is should it be doable to load the players with their respective items: ExoPlayer gets MP3 and TextToSpeechPlayer gets TTS items, but advertise the complete list externally so that if any other controllers connect, like the Notification area UI or AndroidAuto, they can see the complete list and we would switch players internally, typically in onItemTransition or something else, to the player that can play the audio type. It might need more refinement, but that is the idea of what we are wanting to do.

The MediaLibrarySession would be created using the DelegatingPlayer and it would never be changed at that level. Only internally to the DelegatingPlayer would any actual player be switched out. There are going to be issues with things like CastPlayer, since it doesn't support TTS, and other things, but it seems like the concept should work. I think the issue I had when trying to implement it was that the list being reported externally was not the complete list, but the list of the currently playing Player.

It might come down to the Timeline and the fact that I might have to keep my own timeline for the getCurrentTimeline() function.

I'm happy to provide any more clarifying information if requested. The DelegatingPlayer is a large file since it has to implement the entire Player interface and I didn't want to muddy the thread. It's been a couple months since I worked on it also, and it might be out-of-date as well.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions