Javascript 如何隐藏 JWPlayer 播放按钮?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4752112/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to hide the JWPlayer play button?
提问by AJB
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. But, I also read that it returned in version 5.1 ... ?
我在某处读到这可能已在 5.0 版中删除,现在必须使用皮肤来完成。但是,我也读到它在 5.1 版中返回......?
回答by Sebastian Popa
I came acros the same problem and the solution was to set:
我遇到了同样的问题,解决方案是设置:
'controlbar': "none"
Also, I'm using JW Player 5.5.
另外,我正在使用 JW Player 5.5。
Ley me know if it worked out.
让我知道它是否有效。
回答by Whit
You are looking for the "display" plugin. Hide as needed.
您正在寻找“显示”插件。根据需要隐藏。
jwplayer().getPlugin("display").hide();
回答by Peejee
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'
});
回答by Dennis
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.
检查插件部分。
回答by Justin
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;
}
回答by AJB
It seems to be that the 'icons: false' option doeswork, but not with the HTML 5 version of the player. Hopefully they'll get this taken care of with any versions later than JW 5.4.
似乎 'icons: false' 选项确实有效,但不适用于 HTML 5 版本的播放器。希望他们能在 JW 5.4 之后的任何版本中解决这个问题。
回答by Danny G
You can write a flash plugin using the Flex SDK. I have written a base class that inherits from Sprite to handle this.
您可以使用 Flex SDK 编写 Flash 插件。我编写了一个从 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。
回答by Sergey Snegirev
I achieved this by adding 'icons: false' to config. However, JWplayer API reference suggests adding 'controls: false', so try this as well. Here is a working example: http://www.longtailvideo.com/support/jw-player/29241/a-chromeless-player/
我通过在配置中添加“icons: false”来实现这一点。然而,JWplayer API 参考建议添加'controls: false',所以也试试这个。这是一个工作示例:http: //www.longtailvideo.com/support/jw-player/29241/a-chromeless-player/
回答by Simon_Weaver
It's probably quite easy to do with a skin. You can modify an existing skin downloaded from longtail. They're just zip files
使用皮肤可能很容易。您可以修改从 longtail 下载的现有皮肤。它们只是 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. It will just not show the icon then - because it doesn't exist!
基本上,您只需从“显示”目录中的皮肤 zip 文件中删除“playIcon.png”。然后它不会显示图标 - 因为它不存在!
You'll probably have to delete 'background.png' also - or you'll just get a blank square.
您可能还必须删除“background.png” - 否则您只会得到一个空白方块。
回答by javaBean007
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. 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".
使用 6.10 版。上面的其他答案对我不起作用,可能是因为版本更改。我发现的唯一另一种方法是将 skin.xml 播放图标更改为透明图像,但是更多涉及的过程并且更倾向于“黑客”。