设置菜单中的自定义列表

  抱歉,这篇文章有英文版

Hi, I wanted to ask if adding custom download buttons to options menu (under the kogwheel) is possible. I wanted to create buttons like "Download as MKV", "Download as MP4", "Download Subttiles" and pass the link to given file as an argument.

You can add your custom list to the settings menu in the PRO version. Just select Custom menu in one of the items.

In this case, the player will add the MyOption item to the menu with a choice of three options (One, Two and Three).

If you want to make one option without a list, provide just a title.

ow to specify an action

When you click on this item in such a menu, the player will access the global function PlayerjsMenu1 and pass the player id, the name of the selected menu item, and the sequence number of this option as arguments. Then you can use any JS API commands in this function.

function PlayerjsMenu1(id,title,num){
   console.log(id,title,num);
}

You can also specify the API command directly in the option title Title->api:command:option

Playback:Play->api:play,Pause->api:pause
Seek hotkey step:5->api:seekstep:5,10->api:seekstep:10,15->api:seekstep:15
Skin:Red->api:design:1,Blue->api:design:2,Black->api:design:3

How to set the default value

By default, the player selects the first value. But you can specify another by adding options (*) to the name

MyOption:One,Two(*),Three

You can also set the default value in the player code using the menu1 option with the number of the desired option (0,1,2, etc.).

let player = new Playerjs({id:"player", file:URL, menu1:0});

You can also specify the value -1 if there is no single value to choose from in the list and there is no need to mark the current position.

API

You can set the desired value via the API

player.api("menu1",0);

And also get the current value:

player.api("menu1");

20.0.1
2024 © PlayerJS

登录

登录

免费注册

注册
注册即表示您同意服务条款
登录(如果您有帐户)

恢复密码

恢复
忘记电子邮件?联系我们