I already have ExoPlayer 2.7.2
running in my app. I want to add Cast functionality to it. How do I change my vanilla ExoPlayer
to a CastPlayer
using the ExoPlayer Cast extension?
Asked
Active
Viewed 6,885 times
3

khateeb
- 5,265
- 15
- 58
- 114
-
Hi @khateeb, did you see these links? https://medium.com/google-exoplayer/new-cast-extension-and-demo-app-55816a50012 https://developers.google.com/cast/docs/android_sender_integrate – Jaco Apr 04 '18 at 10:03
-
@khateeb, I have to do the same. Did you implement it? do you have any resource I can follow – Akhila Mar 25 '19 at 12:42
-
@AkhilaMadari I followed the steps given in the answer below. – khateeb Mar 26 '19 at 06:31
1 Answers
1
There is a demo app for cast in the ExoPlayer repository on Github which creates a CastPlayer as follows:
// set up the cast player
castPlayer = new CastPlayer(castContext);
castPlayer.addListener(this);
castPlayer.setSessionAvailabilityListener(this);
// set to a PlayerView for controls
castControlView.setPlayer(castPlayer);
Given your code is written against the Player
interface you can swap a local Player with the CastPlayer
instance.
A blog post on Medium explains which cast pieces need to be provided by the app.

marcbaechinger
- 2,759
- 18
- 21
-
https://stackoverflow.com/questions/50972438/android-how-to-use-mediasession-extension-with-castplayer – Hasina Jun 21 '18 at 16:04