简体   繁体   English

如何隐藏JWPlayer播放按钮?

[英]How to hide the JWPlayer play button?

How can I hide the play button that's in the center of the video screen in JW Player? 如何隐藏JW Player中视频屏幕中心的播放按钮?

I'm using version 5.4 of the player and I am embedding it using their own 'JW Embedder' technique. 我正在使用播放器的5.4版本,我使用他们自己的'JW Embedder'技术嵌入它。

I've tried the following with no luck: 我试过以下没有运气:

jwplayer("myPlayer").setup({
   file: 'myMediaFile.mp4',
   image: 'myPosterFile.jpg',
   controlbar: 'bottom',
   icons: false
});

I've read somewhere that this may have been removed with version 5.0 and must now be done with a skin. 我已经在某个地方读到了这个版本5.0可能已被删除,现在必须用皮肤完成。 But, I also read that it returned in version 5.1 ... ? 但是,我也读到它在5.1版本中返回了......?

I came acros the same problem and the solution was to set: 我来了acros同样的问题,解决方案是设置:

'controlbar': "none"

Also, I'm using JW Player 5.5. 另外,我正在使用JW Player 5.5。

Ley me know if it worked out. 嘿,我知道它是否成功。

You are looking for the "display" plugin. 您正在寻找“显示”插件。 Hide as needed. 根据需要隐藏。

jwplayer().getPlugin("display").hide();

Your code should work with JWplayer 5.10 if you put everything between ' ' 如果你把所有东西放在' '之间,你的代码应该适用于JWplayer 5.10

jwplayer("myPlayer").setup({
   'file': 'myMediaFile.mp4',
   'image': 'myPosterFile.jpg',
   'controlbar': 'bottom',
   icons: 'false'
});

For JW Player v6 - HTML5 player: 对于JW Player v6 - HTML5播放器:

You can hide the play button in center of screen in the with CSS: 您可以使用CSS隐藏屏幕中心的播放按钮:

.jwplayer .jwdisplayIcon {
    display: none !important;
}

Or to hide the play button in control bar: 或者隐藏控制栏中的播放按钮:

.jwplay {
    display: none;
}

Add this to your onPause and maybe to your onReady event if you are not using autoplay: 如果您不使用自动播放,请将此添加到onPause,也可以添加到onReady事件:

jwplayer().getPlugin("controlbar").hide();

so it looks like this: 所以它看起来像这样:

jwplayer("container").setup({ 
    events: {
        onPause: function(event){
            jwplayer().getPlugin("controlbar").hide();
        }
    }
})

Reference: http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12540/javascript-api-reference 参考: http//www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/12540/javascript-api-reference

Check the Plugins section. 检查插件部分。

You can write a flash plugin using the Flex SDK. 您可以使用Flex SDK编写Flash插件。 I have written a base class that inherits from Sprite to handle this. 我编写了一个继承自Sprite的基类来处理这个问题。

import flash.display.Sprite;
import flash.display.DisplayObject;
import com.longtailvideo.jwplayer.player.IPlayer;
import com.longtailvideo.jwplayer.view.components.ComponentButton;
import com.longtailvideo.jwplayer.view.interfaces.IControlbarComponent;

public class ExtendedPlugin extends Sprite
{       
    protected var _player:IPlayer;

    public function ExtendedPlugin() 
    {

    }       

    public function hideControlbarButton(buttonName:String):void {
        var controlbar:IControlbarComponent = _player.controls.controlbar;
        var button:DisplayObject = controlbar.getButton(buttonName);    
        button.height = 0;
        button.width = 0;
    }       
}

Then you can write your plugin by inheriting from this class. 然后你可以通过继承这个类来编写你的插件。

public class MyPlugin extends ExtendedPlugin implements IPlugin 
{
     public function initPlugin(player:IPlayer, config:PluginConfig):void 
     {
          _player = player;
     }
}

If you wanted to hide the play and pause buttons for example you would do the following: 如果您想隐藏播放和暂停按钮,例如,您将执行以下操作:

hideControlbarButton("play");
hideControlbarButton("pause");

You will need the correct library imports for this as well. 您也需要正确的库导入。 You will then also need to reference the SWF in the jwplayer parameters. 然后,您还需要在jwplayer参数中引用SWF。

I achieved this by adding 'icons: false' to config. 我通过在配置中添加'icons:false'来实现这一目标。 However, JWplayer API reference suggests adding 'controls: false', so try this as well. 但是,JWplayer API参考建议添加'controls:false',所以也尝试这样做。 Here is a working example: http://www.longtailvideo.com/support/jw-player/29241/a-chromeless-player/ 以下是一个工作示例: http//www.longtailvideo.com/support/jw-player/29241/a-chromeless-player/

It seems to be that the 'icons: false' option does work, but not with the HTML 5 version of the player. 似乎'icons:false'选项确实有效,但不适用于HTML 5版本的播放器。 Hopefully they'll get this taken care of with any versions later than JW 5.4. 希望他们能够在JW 5.4之后的任何版本中使用它。

Here is the situation I came up with: 以下是我提出的情况:

The idea is to disable the controls completely then re-enable them when on user click. 我们的想法是完全禁用控件,然后在用户单击时重新启用它们。

        var jwHandle = jwplayer(videoID).setup(videoConfig);//Set b/c of internal reasons

        //Then when configuring
        autoplay : "false",
        controls : "false", //disable the controls(including play icon)
        events : {
                   onDisplayClick : function(event){
                        //re-enable controls
                        jwHandle.setControls(true);
                       //play the video
                        jwHandle.play();
                    }
                }     
          });

Using version 6.10. 使用版本6.10。 Other answers above did not work for me, probably because of version changes. 上面的其他答案对我不起作用,可能是因为版本更改。 The only other way I found is to change a skin.xml play icon to a transparent image however more involved process and falls more towards side of "hacking". 我发现的唯一另一种方法是将skin.xml播放图标更改为透明图像,但更多涉及过程并且更倾向于“黑客”。

It's probably quite easy to do with a skin. 皮肤可能很容易。 You can modify an existing skin downloaded from longtail. 您可以修改从longtail下载的现有皮肤。 They're just zip files 它们只是zip文件

Here's the documentation : http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/14/building-skins 这是文档: http//www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/14/building-skins

Basically you'd just delete the 'playIcon.png' from the skin zip file in the 'display' directory. 基本上你只需从'display'目录中的skin zip文件中删除'playIcon.png'。 It will just not show the icon then - because it doesn't exist! 它不会显示图标 - 因为它不存在!

You'll probably have to delete 'background.png' also - or you'll just get a blank square. 您可能还必须删除'background.png' - 或者您只是得到一个空白方块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM