问题
I am currently fiddling with an HTML5 video player video.js, which I'd like to add this contextual menu ContextJS to. I am new to this and the more answers I get, I will greatly appreciate.
Thank you in advance.
回答1:
From briefly looking at the ContextJS docs, the first thing you'll want to do is initialize it.
// these are all the defaults
context.init({
fadeSpeed: 100,
filter: null,
above: 'auto',
preventDoubleContext: true,
compress: false
});
Now you can enable the context menu on different items by using context.attach(selector, menuObjects).
It appears that video.js applies the class video-js to all the video player containers it makes. So you can add a context menu to every video on the screen by doing:
context.attach('.video-js', [
{text: 'play', action: function(){ /* code */ }},
{text: 'help', href: '/help.html'}
]);
来源:https://stackoverflow.com/questions/25096840/how-do-i-embed-a-context-menu-into-an-html5-video-player