dominic-p / videojs-resolution-selector

Adds a resolution selector button to Video.js to allow users to manually adjust the video quality.
MIT License
88 stars 31 forks source link

Allow changing resolutions in Flash #9

Open aervans opened 10 years ago

aervans commented 10 years ago

What are the primary road blocks with getting the plugin to work in with Flash? I know there are issues with changing the RTMP source but as far as I know changing an mp4 source seems to work. I'd like to help out with this one so any insight before I start digging in would be helpful.

dominic-p commented 10 years ago

Thanks for your interest in helping. The main roadblock is that I have no experience working with RTMP streaming. It might be as simple as specifying various RTMP sources and having the plugin check the source protocol before it enables the sources as selectable resolutions, but I don't have an RTMP server setup to test it.

As far as I know, you will need RTMP because with just basic flash, the video will have to load from the beginning anytime you change resolutions (see here). That's obviously not the best user experience.

My main concern with RTMP is that the request to start the new source at a specific time may trip up the server. I don't know how video.js will communicate it when you call the player.currentTime() method.

If you are able to tackle this, I would love to see a working test case to get a feel for how it works. Thanks again.

aervans commented 10 years ago

Unfortunately it looks like the RTMP source switching is broken at the moment - https://github.com/videojs/video.js/issues/834. So that's a big problem.

As far as seeking to a specific point - I've had success attaching a .one + playing event and then calling currentTime(). You can see what how I implemented it here: https://github.com/aervans/videojs-seek. I would assume something along the lines of that should work in this case unless changing the source has other implications.

dominic-p commented 10 years ago

Good catch. It looks like we'll have to wait for an update to the Video.js SWF (videojs/video-js-swf#92) before this can be implemented.

As far as the .one + playing event pattern is concerned, that should be fine. I prefer using the loadedmetadata event though because they could change resolutions while the video is paused, meaning the playing event shouldn't fire.

But, unless I'm mistaken, you will still run into the problem of Flash videos having to load from the beginning before they resume play. Do you have a jsfiddle or test case of some kind where you are able to load a video into the Flash tech over HTTP (not RTMP) and start half way through without buffering up to that point?

kenmcd commented 10 years ago

"But, unless I'm mistaken, you will still run into the problem of Flash videos having to load from the beginning before they resume play. Do you have a jsfiddle or test case of some kind where you are able to load a video into the Flash tech over HTTP (not RTMP) and start half way through without buffering up to that point?"

You can start a video at any point with Flash Player by using pseudo-streaming. Search for "Flash Player pseudo-streaming" Both JW Player and Flowplayer support pseudo-streaming, and some other players too. Flowplayer has a pretty good explanation: http://flash.flowplayer.org/plugins/streaming/pseudostreaming.html

YouTube uses pseudo-streaming (using the start parameter). Which is how they switch resolution, pop-out, view on YT, and still maintain the place in the video.

As far as I know right now the VideoJS flash player does not support pseudo-streaming. It has been discussed in the past, but nothing has happened.

dominic-p commented 10 years ago

@kenmcd, that's interesting. I wasn't aware of pseudo-streaming. So, it seems like we're waiting on the video.js flash player for RTMP source switching and/or pseudo-streaming support before we can add flash support to this plugin.

Pseudo-streaming is being tracked on videojs/video-js-swf#13, and it looks like progress is being made. Although, there hasn't been anything new for a few months.

aervans commented 10 years ago

@dominic-p, I think there are more ideal situations than what I had to use in the case of my plugin. The issue that I ran into was that some of the events seemed to work inconsistently across different tech and source combinations. Events on Flash+RTMP stream sources in particular seemed to be broken. After much experimentation the only technique I found to work on pretty much everything was one+play.

I suppose the fact that seeking on Flash is going to require buffing on all but RTMP sources is a bit of a showstopper at the moment. Adding to the problem, source switching on RTMP doesn't work. Essentially changing sources without buffering using Flash isn't going to happen with videojs in it's current form. I guess we'll just have to keep an eye on the videojs issues.

dominic-p commented 10 years ago

Yeah, I think you're right. Once either of the 2 issues we've discussed with the SWF are resolved, we can start looking into this again.

Also, you might be right about the one+play pattern. If we wind up going that route for flash, we'll still have to figure out how to handle cases where the user changes resolutions while the video is paused.

pieroit commented 10 years ago

Same problem here. What do you mean by .one + playing?

Right now I'm trying to add some external buttons (out of the <video>), when they are clicked: 1 - I register the current video time 2 - reload the player giving a differente source 3 - re-seek as it was before.

Is this a viable approach? I don't know how to do it from a videojs plugin. Thank you :)

@dominic-p : I made a bower package for a fork of your plugin... if you make one yourself I delete mine (I can pull request to you the bower.json in case).

dominic-p commented 10 years ago

@pieroit, .one + playing is just our shorthand for saying you register a one time handler for the playing event. The basic strategy you outlined will work for an HTML5 video (it's roughly how this plugin works), but for Flash you will run into the problems we've been discussing on this issue.

Regarding the bower package, I appreciate you taking the time to do that, but honestly I feel like it's a bit of overkill for this project. We're talking about a single js file. I feel like a package management system would only add some unneeded complexity at this point.

hxdev commented 9 years ago

Anything new guys?

dominic-p commented 9 years ago

@hxdev, still no movement on either of the SWF issues this depends on (#92 and #13). Once those issues are resolved, then we can think about implementing this plugin for Flash.

hxdev commented 9 years ago

@dominic-p Thanks, yesterday I've try small test about the seek on html5 and flash, look like flash has big problem with that hmmm. Anyway, keep waiting for the better news :8ball: