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

Add Video/Audio Media Events #4370

Merged
merged 1 commit into from
Jul 30, 2015
Merged

Conversation

blainekasten
Copy link
Contributor

@see https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Media_events
This adds the following event options to video and audio dom components:

onPause onLoadStart onPlay onPlaying onCanPlay onCanPlayThrough onAbort onEnded onSeeking onSeeked onVolumeChange onError onDurationChange onEmptied onLoadedData onLoadedMetadata onEncrypted onProgress onRateChange onStalled onSuspend onTimeUpdate onWaiting

@jimfb
Copy link
Contributor

jimfb commented Jul 14, 2015

I don't see any reason not to add them, might as well include all the events. cc @zpao

topDragOver: eventTypes.dragOver,
topDragStart: eventTypes.dragStart,
topDrop: eventTypes.drop,
topPause: eventTypes.pause,
Copy link
Contributor

Choose a reason for hiding this comment

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

Please keep all lists sorted.

@blainekasten
Copy link
Contributor Author

@jimfb I added the rest of them and updated the title.

@blainekasten blainekasten changed the title Add Most Video Events Add Video Events Jul 14, 2015
@@ -322,6 +322,70 @@ function trapBubbledEventsLocal() {
),
];
break;
case 'video':
inst._wrapperState.listeners = [
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure about this, but this is superfluent I believe. This is only for events that explicitly can emit events the instant the node is mounted into the DOM (and otherwise risk getting lost). Perhaps it applies to some of these onLoadStart (etc) perhaps, but I'm sure it does not apply to all of them.

@jimfb @zpao correct me if I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My understanding was that this function was for events that can't be caught at the global level and need to be attached to the actual dom node. For example, media events don't bubble and can only be received on the media node.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oooh, yeah that too. All good then :)

@blainekasten
Copy link
Contributor Author

One thing that I didn't do is make an extension to the SyntheticEvent for media stuff. Looking into the specs it doesn't seem that the MediaEvents do anything particularly special. I'm assuming the answer to this will be to follow the spec, but we could add some useful helper information to a SyntheticMediaEvent. Things like:

Float percentLoaded
Bool muted
Float volumeLevel
Object metadata
...

cc @zpao

topEnded: null,
topSeeking: null,
topSeeked: null,
topVolumeChange: null,
Copy link
Member

Choose a reason for hiding this comment

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

Shouold probably keep this ABC order too

@zpao
Copy link
Member

zpao commented Jul 28, 2015

Sorry for the delay! A few things...

What about <audio>? Do these overlap 100%? Might be good to get support for both at the same time.

As for Synthetic events, yea, we should stick to spec.

@blainekasten blainekasten changed the title Add Video Events Add Video/Audio Media Events Jul 29, 2015
@blainekasten
Copy link
Contributor Author

@zpao no worries!

I did some research, the events do overlap 100%, so i included audio in the event handling.

I think this PR should be good to go. I didn't see any obvious/good place to put tests in. Maybe I missed that? Or maybe this is something you guys just don't worry about testing?

@@ -322,6 +322,49 @@ function trapBubbledEventsLocal() {
),
];
break;
case 'video':
case 'audio':
var mediaEvents = {
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't be inline (to avoid unnecessary overhead).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean I should just copy the code for audio and video? What's the benefit in that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, no I meant to put it outside the function since it's a static object, so it isn't recreated every time it's called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gotcha. Donezies

@jimfb
Copy link
Contributor

jimfb commented Jul 29, 2015

Last call for feedback on this PR. Otherwise, looks good to me.

@blainekasten There are 12 commits in this PR; can you squash them together so we can merge?

@jimfb jimfb self-assigned this Jul 29, 2015
@blainekasten blainekasten force-pushed the video-events branch 2 times, most recently from 9bf3c84 to bdf377f Compare July 30, 2015 04:49
@blainekasten
Copy link
Contributor Author

That was surprisingly difficult. But it's done. @jimfb Thanks!

jimfb added a commit that referenced this pull request Jul 30, 2015
@jimfb jimfb merged commit cc98f83 into facebook:master Jul 30, 2015
@jimfb
Copy link
Contributor

jimfb commented Jul 30, 2015

Great, thanks @blainekasten!

@blainekasten
Copy link
Contributor Author

Woo hoo! @jimfb, do I assume that this will be included in 0.14 then?

@jimfb
Copy link
Contributor

jimfb commented Jul 30, 2015

@blainekasten Correct, that's the plan!

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.

5 participants