sambatech / player_sdk_android

Samba Player SDK for Android
15 stars 8 forks source link

SambaCast: I can't using .pauseCast() method #3

Open luisfelipeas5 opened 7 years ago

luisfelipeas5 commented 7 years ago

I followed the tutorial to set the SambaCast in the player and I can see the casting working perfectly.

When I use sambaCast.stop() method the casting stops. But sambaCast.pauseCast() and sambaCast.playCast() aren't working. My goal is use this method in a notification media controller, but this doesn't work, even if I try:

@Override
protected void onPause() {
    super.onPause();
    mSambaCast.pauseCast();
}
lzanol commented 7 years ago

Hello @luisfelipeas5, I don't know exactly what was your scenario, but the method pauseCast() takes into account the state of the cast session, it must be in connected state for you to control it (e.g. connecting state is invalid).

As stated in the link you've sent, try using pause() method from SambaPlayer class instead. When player is casting, its methods (play, pause, stop...) control the remote cast player on Chromecast and not the local one.

Please let me know if this solves your problem.

Best

luisfelipeas5 commented 7 years ago

So, I want pause the state of the cast session.

And sorry, I forgot to say: the onPause() method that I put before is from my Activity. And even though, the Cast session don't pause.

It's weird because looking at the LogCat the follow message is appeared:

Message Sent OK: namespace:urn:x-cast:com.sambatech.player message:urn:x-cast:com.sambatech.player

lzanol commented 7 years ago

I've tried doing the same here and it seems to work. Here's my flow:

  1. Start video
  2. Press cast button, choose a device
  3. Once it is casting, I pressed the Android "square" button to cause the Activity to pause (calls onPause())
  4. I then called SambaPlayer.pause() method and the remote cast player paused correctly

Could you please provide me the project ID and media ID of the media you're testing? This way I can better simulate it here.

luisfelipeas5 commented 7 years ago

The project ID is and the media ID is.

But my doubt is: what does SambaCast.pauseCast() do?

Because I want pause the cast session by the Notification control and I'm trying use this method and not the SambaPlayer.pause(). Am I wrong? Do I must use SambaPlayer.pause() instead of SambaCast.pauseCast()?

lzanol commented 7 years ago

In the end SambaPlayer.pause() will call SambaCast.pauseCast() (when casting), but it'd be a better choice to use SambaPlayer.pause() because, before pausing cast, it dispatches the PAUSE event and also stops the progress event timer (to stop seekbar update on local player).

I just didn't get very well this Notification approach you're using to get this done. Could you please provide more context?

lzanol commented 7 years ago

By the way, are you trying to pause a media that is casting or the Chromecast session?

PS: A propósito, podemos falar em Português se preferir. :)

luisfelipeas5 commented 7 years ago

Oh, I got it. But I tried use SambaPlayer.pause(), but didn't work.

I'm trying pause the media that is casting.

I want implement this:

  1. I play a video and connect with a Chromecast device;

  2. When I exit of the screen of the player in the device, a notification appears with three actions. Like: alt tag

  3. The notification control the SambaPlayer with a Service and when the user clicked in:

    1. pause icon: the media that is casting pauses
    2. play icon: the media that is casting plays
    3. close icon: the media stops to be casting

PS: ah sim, obrigado. Mas acho que o português pode não ser a língua do próximo a ter esse problema e ler essa Issue, correto? E aproveitando, desculpe pelo meu inglês que não é muito bom

lzanol commented 7 years ago

Now I see, the point is that when you exit the activity containing the player instance, it'll get destroyed and won't respond anymore.

So in your case it does make sense calling SambaCast.pauseCast(). It should work.

I'll try some debugging here on my side and get back to you as soon as I have some news.

PS: Não esquenta, sem erro! ;)