How to add an additional button to the controlbar with jwplayer 7

走远了吗. 提交于 2019-12-29 00:46:14

问题


I am interested in adding a download video button, similar to the one here -- http://support.jwplayer.com/customer/portal/articles/1436999-example-adding-a-download-button. However, I would like to add it within the control bar (a download arrow to the far right).

How would I add in additional buttons to the controlbar in jwplayer 7?


回答1:


playerInstance.on('ready',function() {
                    if (jwplayer().getRenderingMode() == "html5"){
                        videoTag = document.querySelector('video');
                         if(videoTag.playbackRate) {
                            playerInstance.addButton(
                                "icon_dir.png",
                                "0.25x", 
                                function() {
                                  changeSpeed(0.25);
                                },
                                "0p25xslow"
                            );

                            playerInstance.addButton(
                                "icon_dir.png",
                                "0.5x", 
                                function() {
                                  changeSpeed(0.5);
                                },
                                "0p5slow"
                            );

                            playerInstance.addButton(
                                "icon_dir.png",
                                "1x", 
                                function() {
                                  changeSpeed(1);
                                },
                                "1xnormal"
                            );

                            playerInstance.addButton(
                                "icon_dir.png",
                                "1.5x", 
                                function() {
                                  changeSpeed(1.5);
                                },
                                "1p5xforward"
                            );

                            playerInstance.addButton(
                                "icon_dir.png",
                                "2x", 
                                function() {
                                  changeSpeed(2);
                                },
                                "2xforward"
                            );
                        }
                    }
                    else{
                        alert("your browser doesn't support HTML5,cant't change speed.");
                    }
                    console.log("state is :"+playerInstance.getState());
                });



回答2:


For JW Player 7.3 you can do this via JS

    playerInstance.onReady(function(){
            var myLogo = document.createElement("div");
            myLogo.id = "myTestLogo";
            myLogo.setAttribute('style',"color: red; padding-left: 5px; margin-right: 5px; margin-top: 10px; background-image: url('/icon_dir.png');background-repeat: no-repeat;");
            myLogo.setAttribute('class','jw-icon jw-icon-inline jw-button-color jw-reset jw-icon-logo');
            myLogo.setAttribute('onclick','window.location="http://jwplayer.com"');
            document.getElementsByClassName('jw-controlbar-right-group')[0].appendChild(myLogo);
    });


来源:https://stackoverflow.com/questions/32189495/how-to-add-an-additional-button-to-the-controlbar-with-jwplayer-7

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