Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chromecast SDK (Android) - is there a way to check whether the media playing on the cast device has finished playing?

Is there an onFinished listener of some sort? Or do we have to compare the current stream position against the duration of the track?

like image 873
Prem Avatar asked Oct 28 '13 22:10

Prem


People also ask

Can you cast live streaming?

Cast Your Entire Android ScreenMake Sure your mobile phone or tablet is on the same Wi-Fi network as your Chromecast device. Open the Google Home app (The Rainbow app that looks like a house). Tap the device you want to cast your screen to. Tap 'Cast my screen' icon (It looks like a box with a Wi-Fi symbol).

How do I play media on Chromecast?

Make sure your mobile device or tablet is connected to the same Wi-Fi network or linked to the same account as your speaker or display. Open a Chromecast-enabled app. Tap the Cast icon .

Can you broadcast from phone with Chromecast?

Mirror your Android phone or tablet screen to the TVFrom your Android phone or tablet, open the Google Home app. Tap the left hand navigation to open the menu. Tap Cast screen / audio and select your TV.


2 Answers

It's not pretty but you can make this call:

if (mRemoteMediaPlayer.getMediaStatus().getPlayerState() ==  MediaStatus.PLAYER_STATE_IDLE
    && mRemoteMediaPlayer.getMediaStatus().getIdleReason() ==  MediaStatus.IDLE_REASON_FINISHED) {
  ...

}
like image 187
Silva2351 Avatar answered Sep 28 '22 15:09

Silva2351


Prem, There is currently no callback to register for such event. One alternative (and-not-so-pretty) approach is the following: on the receiver, listen for "ended" event of the media element and send an event back to the sender through a private channel. Another approach is what you suggested: check position against duration. When SDK graduates to general availability, better and cleaner approaches will be available to accomplish what you want.

like image 20
Ali Naddaf Avatar answered Sep 28 '22 16:09

Ali Naddaf