Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tech 2.0 #2057

Closed
wants to merge 26 commits into from
Closed

Tech 2.0 #2057

wants to merge 26 commits into from

Conversation

eXon
Copy link
Contributor

@eXon eXon commented Apr 22, 2015

I'm starting a pull request to make sure I'm working in the right direction and that everyone agrees with that. (#2008)

By the way I couldn't test Flash because videojs.options doesn't exists anymore so I can't set the swf path.

Let me know what you guys think.

Roadmap

@gkatsev
Copy link
Member

gkatsev commented Apr 22, 2015

You should be able to pass in the swf via an option to the player you're creating:

videojs('foo', {
  flash: {
    swf: "http://google.com"
  }
});

Which reminds me, we probably want a way to change these defaults globally so you won't be required to specify it for each player.

@@ -321,7 +321,7 @@ Flash['checkReady'] = function(tech){
// Trigger events from the swf on the player
Flash['onEvent'] = function(swfID, eventName){
let player = Lib.el(swfID)['player'];
player.trigger(eventName);
player.tech.trigger(eventName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should store a reference to the tech on the swf object, probably after it's created. Then we don't need to reference the player here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think the placeholder was actually a remnant of using swfobject.js, which required you to replace an existing element. #1340 got us a little closer but I think the placeholder could be refactored out now.

This specific line though is the swf's reference to the tech, not the tech's reference to the swf. We need the swf to have a reference because the Flash events get triggered globally and we need to figure out which tech they apply to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an out-dated diff (I think I misplaced my comment for the placeholder). It is now:

let tech = Lib.el(swfID)['tech'];
tech.trigger(eventName);

and the tech is saved within the element instead of the player.

@heff
Copy link
Member

heff commented Apr 23, 2015

Looking great so far!

@eXon
Copy link
Contributor Author

eXon commented Apr 23, 2015

@gkatsev The option is now working. However, it seems like Flash is never sending me the onReady event. Any clue?

I'm on Ubuntu / Chrome and Flash works fine.

@@ -26,9 +26,6 @@ class Flash extends Tech {

let { source, parentEl } = options;

// Create a temporary element to be replaced by swf object
let placeHolder = this.el_ = Lib.createEl('div', { id: player.id() + '_temp_flash' });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to guess why we were using this placeholder and I ended up looking at 2 years old commits. My only guess is that it was needed in the iframe mode. It seems to work perfectly fine without using it. @heff any clue?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the placeholder used to be required for the flash fallback back in the day. I think it can be safely removed now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, placeholder can be removed now.

* Fires when the browser is intentionally not getting media data
* @event suspend
*/
onTechSuspend() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these simple ones we could probably loop though a list of the events and create these dynamically. Though it is kind of nice to have an excuse to add the event jsdoc tag.

@heff
Copy link
Member

heff commented Apr 23, 2015

So it looks like we previously broke Flash. The swf is still told to fire the videojs.Flash.onReady event, but we've changed that to just Flash.onReady, and it's no longer available globally. We'll need to re-export that to the window some how.

In videojs/video-js-swf#143 we hardcoded these functions to prevent security issues. So either we'll need to expose window.videojs everywhere again, or create new global functions and release a new version of the swf.

@gkatsev
Copy link
Member

gkatsev commented Apr 23, 2015

It would be awesome if we export a different flash-onready function per player on the window object :)

@heff
Copy link
Member

heff commented Apr 23, 2015

Is there a way we can do that without opening the security hole back up?

@gkatsev
Copy link
Member

gkatsev commented Apr 24, 2015

Oh, right, completely forgot about that. Hm...

this.on(this.tech, 'pause', this.onTechPause);
this.on(this.tech, 'progress', this.onTechProgress);
this.on(this.tech, 'durationchange', this.onTechDurationChange);
this.on(this.tech, 'fullscreenchange', this.onTechFullscreenChange);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fullscreenchange is actually a player event, not tech.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fullscreenchange listener could still be removed, now that you've added it to the player.

@eXon
Copy link
Contributor Author

eXon commented May 2, 2015

Hopefully I have addressed everything here and we can move on smaller PR now :)

@eXon
Copy link
Contributor Author

eXon commented May 2, 2015

Big thanks for the merge by the way @heff, very helpful

@gkatsev
Copy link
Member

gkatsev commented May 4, 2015

Looks like you need to rebase against master again, sorry. On the bright side, the flash tech should be working again :)

@eXon
Copy link
Contributor Author

eXon commented May 4, 2015

Yay! I'll try tonight :)

On Mon, May 4, 2015 at 2:42 PM Gary Katsevman [email protected]
wrote:

Looks like you need to rebase against master again, sorry. On the bright
side, the flash tech should be working again :)


Reply to this email directly or view it on GitHub
#2057 (comment).

@eXon
Copy link
Contributor Author

eXon commented May 5, 2015

Flash is working perfectly now :) let's merge this

var techReady = function(){
this.player_.triggerReady();
};
var techReady = Lib.bind(this, function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@heff heff mentioned this pull request May 6, 2015
8 tasks
@heff
Copy link
Member

heff commented May 6, 2015

I want to go ahead and pull this in to prevent further merge conflicts, but there's a list of follow tasks we'll need to do to really finish it off. See #2126.

@heff heff closed this in e5595b1 May 6, 2015
@eXon
Copy link
Contributor Author

eXon commented May 6, 2015

Awesome :) I'll take a closer look at all this in the upcoming days

@heff
Copy link
Member

heff commented May 6, 2015

Woo!

@heff
Copy link
Member

heff commented May 6, 2015

@eXon do you think you could add any relevant notes for other tech developers to the 5.0 changes?
https://github.com/videojs/video.js/wiki/5.0-Change-Details

@eXon
Copy link
Contributor Author

eXon commented May 6, 2015

Of course. You can add this to #2126

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants