kim-company / videojs-chromecast

Google Chromecast VideoJS Plugin
MIT License
84 stars 42 forks source link

Continuous playback ability #7

Open joeedwards opened 9 years ago

joeedwards commented 9 years ago

fantastic plugin!

I was trying to put together a prototype with videojs and plugins. I am using:

videojs videojs-playlist [ https://github.com/tim-peterson/videojs-playlist ] videojs-chromecast

I know there is no "continuous" mode with videojs, what the playlist attempts is to load the next video when the "ended" event is fired. This works when the chromecast plugin is not initialized, however, when it is the following error is thrown:

Uncaught TypeError: undefined is not a functionvideojs.chromecast.js:262 vjs.ChromecastComponent.ChromecastComponent.onStopAppSuccess

It appears that this.player.src(this.player.options_["sources"]); is empty, is it reading from videojs's src? (eg: videojs.src() )

thanks, -joe

philipgiuliani commented 9 years ago

Hi, thanks for reporting the issue.

The latest VideoJS version has changed a lot in the .src function. I started yesterday with trying to fix the bug, but wasnt able to find a working solution quickly.

I'm currently busy, but i will have time on Monday to fix and test it. I will also test videojs-playlist with it.

If you are able to fix it in the meantime, feel free to open a PR. You can find the building instructions here.

joeedwards commented 9 years ago

Hi Philip,

I removed the playlist plugin. I am using your video.dev.js and not the latest VideoJS. If I do not Cast, when the video stops playing (when not using the playlist plugin), there is no error. When I cast to my chromecast, when the video stops playing, that error is thrown.

-joe

philipgiuliani commented 9 years ago

Yes thats the error im trying to fix. Try to use VideoJS 4.10.2, that worked fine. I will fix the latest version soon!

joeedwards commented 9 years ago

I'm using what you have here ( https://github.com/kim-company/videojs-chromecast/tree/master/demo ). I think it is v4.10.2, correct? I get the error when the video stops casting. I would be fine sticking with v4.10.2 for this for a while, but like I said, the error is there. I can't get the latest version of videoJS to work at all with your plugin.

philipgiuliani commented 9 years ago

Oh we didn't noticed the error with v4.10.2. Thanks a lot for testing it, i will fix it this week!

joeedwards commented 9 years ago

I don't think the cast session is supposed to idle or stop until the user/sender tells it to. The issue appears to be in the onStopAppSuccess method. I also do not understand videojs' tech very well. It would appear the plugin would need to keep the requested cast session open and allow new source to be added to mediaInfo. Your plugin, understandably by design, was not made to receive src updates - can you adjust it to receive src updates?

-- update-- I commented out the onStopAppSuccess for testing. I added a 'addSource(source)' to your ChromecastComponent prototype chain and added an "ended" event trigger in onMediaStatusUpdate() IDLE conditional. Now that the plugin doesn't stop the CC session and triggers when the playback ends, I am able to play the next video! This is with videojs.dev v4.10.2

I should add that in that addSource method I created a new chrome.cast.media.MediaInfo and called the loadRequest and apiSession.loadMedia.

philipgiuliani commented 9 years ago

Hi! Thanks a lot for your effort.

I looked at the updated API in the Tech Controllers of Video.JS. The source will now also be set by setSource, that also has to be added. I will adapt the tech to be able to change the source without disconnecting the Chromecast.

If you want you can also dig into it and make a PR! Just tell me if i should do it :)