How do I embed a context menu into an HTML5 video player?

拜拜、爱过 提交于 2019-12-11 09:53:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!