lihaosky / google-cast-sdk

Automatically exported from code.google.com/p/google-cast-sdk
0 stars 0 forks source link

cast.receiver.media.Player#load(contentId, true, 123) does not autoplay video #518

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. call cast.receiver.media.Player#load(contentId, true, 123)
2. watch if video starts playing

What is the expected output? What do you see instead?
the video buffers but never starts playing

Please provide any additional information below.
I tried to set the autoplay property of the mediaElement before calling load(). 
this fixes it when I want autoplay to be true.
but when I want autoplay to be false it doesn't work. the video then always 
plays. even when I call cast.receiver.media.Player#load(contentId, false, 123) 
and autoplay of the media element is false.

I think this bug was introduced with the latest media player library update

Original issue reported on code.google.com by p...@zattoo.com on 3 Mar 2015 at 5:10

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
it looks like I mixed up
https://developers.google.com/cast/docs/reference/receiver/cast.receiver.media.P
layer#load
and
https://developers.google.com/cast/docs/reference/player/cast.player.api.Player#
load

anyway I still have the problem that setting autoplay to false is not working 
anymore in a custom receiver.

when I set mediaElement.autoplay = false and then call 
cast.player.api.Player#load(protocol, offset) the video still starts playing 
after some buffer time

Original comment by p...@zattoo.com on 3 Mar 2015 at 5:43

GoogleCodeExporter commented 9 years ago
It is recommended that autoplay is configured using the media namespace from 
the sender. If you want to control it in your receiver directly then you can 
refer to this sample: 
https://github.com/googlecast/CastVideosPlaylist-chrome/blob/master/player_playl
ist_receiver.html
You can also have a look at our reference receiver on how to handle autoplay: 
https://github.com/googlecast/Cast-Player-Sample.

Please let us know if the issue still persist and we can reopen it.

Original comment by na...@google.com on 3 Mar 2015 at 11:03

GoogleCodeExporter commented 9 years ago
that is what I'm doing. the sender sets the autoplay property in the 
LoadRequest, but because I need support for adaptive streams I have a custom 
receiver with a custom onLoad callback where I need to handle autoplay on my 
own.
my reference for this was this code: 
https://github.com/googlecast/cast-custom-receiver/blob/master/sample_media_rece
iver.html#L465-L523
but autoplay is not handled in there. it's just always true.

this is how I did it in the onLoad callback which used to work but is not 
anymore (simplified):

mediaManager.onLoad = function (event) {
    var autoplay = (event.data.autoplay === false ? false : true); // default to autoplay = true
    mediaElement.autoplay = autoplay;
    mediaHost = new cast.player.api.Host({mediaElement: mediaElement, url: event.data.media.contentId});
    mediaPlayer = new cast.player.api.Player(mediaHost);
    protocol = cast.player.api.CreateSmoothStreamingProtocol(mediaHost);
    mediaPlayer.load(protocol, 123);
};

it always autoplays, even when the LoadRequest has autoplay value of false

Original comment by p...@zattoo.com on 4 Mar 2015 at 9:09

GoogleCodeExporter commented 9 years ago
sorry I used the wrong protocol in the last comment. most of the time we use HLS

Original comment by p...@zattoo.com on 4 Mar 2015 at 9:13

GoogleCodeExporter commented 9 years ago
There's no known bug in MPL related to autoplay. Also, we could not repro the 
issue with the information provided. Please make sure that the player is 
unloading properly between loads and try debugging at your end. 

If the issue persist, please provide a sample (and other relevant info) which 
would help reproduce the issue. We'd be glad to help you with it. 

Original comment by na...@google.com on 4 Mar 2015 at 10:06

GoogleCodeExporter commented 9 years ago
ok found it. some refactoring introduced that mediaElement.autoplay got set 
before doing mediaPlayer.unload() which was before the other way around. 
reverting that change fixed it.

but I'm still not sure why the mediaPlayer is not respecting the value of 
mediaElement.autoplay when it is still "running" (not unloaded before or never 
load()ed).
it should work in both ways which is currently not the case.

anyway thanks for your feedback!

Original comment by p...@zattoo.com on 6 Mar 2015 at 3:06