Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cast example #248

Open
wants to merge 1 commit into
base: minor
Choose a base branch
from
Open

Cast example #248

wants to merge 1 commit into from

Conversation

Marekkon5
Copy link

Hello, some time ago I created issue #211 asking for cast support, and I made a proof-of-concept that barely works. This PR isn't meant to be merged, it's just to show a working example.

What this example does:

Added 2 new functions (getAvailableCastDevices, connectCast) that allow listing available cast devices, and connecting to them.
When connected a hardcoded example song is being played, it is because the CastPlayer uses different queueing / MediaSources than the default ExoPlayer.
Play, pause, seeking, updating position affect the cast player when connected.

How to:

Just run the example app, and you can press the cast button. I personally do not own any cast devices, so I used AirScreen app on another device to emulate one.
Note 1: You might need to connect twice to start playback because it sometimes throws unknown error.
Note 2: You need to press the play/pause button when cast started to update the UI to control the remote playback.

I know that this example is really barebones, barely working, but let me know if you find it useful or gonna work on this feature. Thank you for the amazing library!

@ryanheise
Copy link
Owner

Thanks for this example! It's a feature I'd definitely like to see and this is certainly a useful first step.

I haven't fully looked into the API documentation yet, so my only exposure is through reading your code. I know even less about AirPlay, so that will be the next thing for me to understand before figuring out how to unify the two APIs and create a Dart API.

@keaganhilliard
Copy link

Just wanted to point out that Cast is supported on iOS as well, but it would likely be a larger lift than using the exoplayer castplayer implementation. Not sure how that would factor into the airplay and cast architecture. There is interesting crossover with audio_service as well. You are technically supposed to create a notification showing that something is casting and there's a CastSession as well which kind of aligns to MediaSession and you also need to pass metadata over to the Cast device. All of this is handled audio_service which kind of blurs the lines between these two packages. Almost like the functionality would have to be implemented in both places, but that would also likely involve using the SDK directly rather than using exoplayer's stuff on the audio_service end of things. I could be overcomplicating it 🤷

@ryanheise
Copy link
Owner

That's interesting to think about. What are the requirements for an app? When switching from the regular player to the cast player, it needs to:

  • stop the media session
  • start the cast session

Does it need to co-opt audio_service's media notification, or is it OK to shut it down and start a new notification?

@keaganhilliard
Copy link

As far as I can tell it's fine to kill the notification and create a new one. I've seen other apps do that.

https://developers.google.com/cast/docs/design_checklist/sender#sender-control-notification

They have a lot of opinions about how you handle the cast stuff in your app as well haha

@ryanheise
Copy link
Owner

OK, that technically means no changes need to be made to audio_service, however I'd rather think through the alternative solutions thoroughly first before deciding anything.

If we reuse audio_service's notification, we can leverage its callback and isolate management, but then we also need to solve the problem of sharing the cast session between audio_service and just_audio which implies extracting parts of this out into a 3rd plugin.

@markst
Copy link

markst commented Jul 1, 2023

@Marekkon5 have you followed any of the discussion in #211?

@Marekkon5
Copy link
Author

@markst Thank you for the reminder, however I am no longer working on any Flutter project related to this, so I've abandoned it. Sorry for ignorance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants