Last active
November 26, 2015 17:29
-
-
Save wildeyes/b9581f739ba810908467 to your computer and use it in GitHub Desktop.
Patch VLC events so that they'll be routed to Meteor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example usage: | |
// Meteor.SOMELAYOUT.events({ | |
// "embed MediaPlayerPositionChanged": function(value) { | |
// console.log("Position is now at ", value); | |
// } | |
// }); | |
if(Meteor.isClient) { | |
Meteor.startup(function() { | |
var embed = document.querySelector('embed'), | |
events = { | |
"MediaPlayerNothingSpecial": [], | |
"MediaPlayerOpening": [], | |
"MediaPlayerBuffering": [], | |
"MediaPlayerPlaying": [], | |
"MediaPlayerPaused": [], | |
"MediaPlayerStopped": [], | |
"MediaPlayerForward": [], | |
"MediaPlayerBackward": [], | |
"MediaPlayerEndReached": [], | |
"MediaPlayerEncounteredError": [], | |
"MediaPlayerTimeChanged": ['time'], | |
"MediaPlayerPositionChanged": ['val'], | |
"MediaPlayerSeekableChanged": ['val'], | |
"MediaPlayerPausableChanged": ['val'], | |
"MediaPlayerMediaChanged": [], | |
"MediaPlayerTitleChanged": ['val'], | |
"MediaPlayerLengthChanged": ['val'] | |
} | |
for (eventName in events) { | |
var args = events[eventName]; | |
embed.addEventListener(eventName, function() { | |
var arg = args[0], | |
data = {}; | |
if(args.length > 0) | |
data[arg] = arguments[0] | |
embed.dispatchEvent(new CustomEvent(eventName, data)); | |
}, false); | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment