为什么我的播放列表不起作用?
交叉发布在 Flowplayer 论坛上,但尚未回复,所以我希望这里有人可以帮助。
我使用播放列表插件完全没有成功。我按照 http://flowplayer.org/plugins/javascript/playlist.html 中的示例进行操作 密切关注,我让初始剪辑正常工作,但播放列表插件似乎没有注册。视频加载并播放,因此 FlowPlayer 加载正确,但播放列表没有向我的播放列表对象附加任何功能。
我确认播放列表脚本正在加载:我将 alert("playlist!");
添加到 flowplayer.playlist-3.0.8.js
的顶部,就在初始注释块和功能代码开始之前。当我加载网页时,我会看到警报。无论是使用脚本的缩小版本还是普通版本,也无论使用 flowplayer()
还是 $f()
调用 flowplayer 函数,我都会得到相同的结果。我正在使用 flowplayer 3.2.3
和 playlist 3.0.8
。
这是一个极其简单的静态页面,尝试在图库中渲染 FlowPlayer 和两个剪辑: FlowPlayer 出现,但单击任一图库链接会将当前页面替换为直接在浏览器窗口中播放的视频,而不是让我一直在浏览器中播放。 HTML 页面并在 FlowPlayer 实例中播放视频。
如果我向 FlowPlayer 调用添加配置参数并提供默认剪辑,则该剪辑会播放,但图库链接只会将我带到原始剪辑,而不是将剪辑推入 FlowPlayer。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test flowplayer</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="/_library/script/flowplayer/flowplayer-3.2.3.min.js" type="text/javascript"></script>
<script src="/_library/script/flowplayer/flowplayer.playlist-3.0.8.min.js" type="text/javascript"></script>
</head>
<body>
<div id="player" style="display: block; width: 776px; height: 432px;"></div>
<div id="gallery">
<a href="/resources/video/Empowerment_TV30_776.mp4">video 1</a>
<a href="/resources/video/Commercial_776.mp4">video 2</a>
</div>
<script type="text/javascript">
$(function () {
$f("player", "/_library/script/flowplayer/flowplayer-3.2.3.swf")
.playlist("gallery");
});
</script>
</body>
</html>
知道我做错了什么吗?感谢任何帮助,如果您需要更多详细信息,请告诉我。
谢谢! - 瓦尔
Cross-posted on the Flowplayer forums, but no response there yet, so I hope someone here could help.
I'm having no success at all using the Playlist plugin. I've followed the examples at http://flowplayer.org/plugins/javascript/playlist.html closely, and I get the initial clip to work, but the Playlist plugin does not seem to register. The video loads and plays, so FlowPlayer is loading properly, but playlist doesn't attach any functionality to my playlist objects.
I confirmed that the playlist script is loading: I added alert("playlist!");
to the top of the flowplayer.playlist-3.0.8.js
, just after the initial comment block and before the start of the function code. When I load my web page, I see the alert. I get the same results whether using the minified or normal versions of the scripts, and whether I call the flowplayer function with flowplayer()
or $f()
. I'm using flowplayer 3.2.3
and playlist 3.0.8
.
Here's a dead-simple static page that tries to render a FlowPlayer and two clips in a gallery: FlowPlayer appears, but clicking on either of the gallery links replaces the current page with the video playing directly in the browser window, instead of keeping me on the HTML page and playing the video in the FlowPlayer instance.
If I add a config param to the FlowPlayer call and provide a default clip, then that clip plays, but again the gallery links just take me to the raw clip, rather than pushing the clip into the FlowPlayer.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test flowplayer</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script>
<script src="/_library/script/flowplayer/flowplayer-3.2.3.min.js" type="text/javascript"></script>
<script src="/_library/script/flowplayer/flowplayer.playlist-3.0.8.min.js" type="text/javascript"></script>
</head>
<body>
<div id="player" style="display: block; width: 776px; height: 432px;"></div>
<div id="gallery">
<a href="/resources/video/Empowerment_TV30_776.mp4">video 1</a>
<a href="/resources/video/Commercial_776.mp4">video 2</a>
</div>
<script type="text/javascript">
$(function () {
$f("player", "/_library/script/flowplayer/flowplayer-3.2.3.swf")
.playlist("gallery");
});
</script>
</body>
</html>
Any idea what I'm doing wrong? Any help appreciated, let me know if you need more details.
Thanks!
- Val
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
$f("player", "/_library/script/flowplayer/flowplayer-3.2.3.swf").playlist("gallery");
也许?
.playlist()
不是$(function () {})
的函数$f("player", "/_library/script/flowplayer/flowplayer-3.2.3.swf").playlist("gallery");
maybe?
.playlist()
is not a function of$(function () {})
这是为
load
事件 注册事件处理程序的方式。因此,直到浏览器触发load
事件后,其中的代码才会执行,并且该插件可能尚不可用。另外,您没有仔细遵循教程。代码如下
请注意,
.playlist
是在$f()
返回时调用的,而不是在$(function(){... })
。Is how you register an event handler for the
load
event. Because of this,The code within it is not executed until theload
event is fired by the browser and it is possible that the plugin is not available yet.Also, you are not following the tutorials closely. The code the have is like this
Note that
.playlist
is called on the return of$f()
, not on$(function(){...})
.好的,已修复。
许多示例都使用播放列表容器上的类。在使用类的示例中,播放列表函数传递给 CSS 选择器 - 通常类似于
playlist("div.gallery")
我更改了标记以使用类,将参数更改为
playlist()
到一个完全合格的 CSS 选择器,并且它有效!现在,我不想使用类——我有一个播放列表元素,所以我想使用 ID。我将标记更改回 ID:
并将调用者更改为使用 ID: 的 CSS 选择器,
这也有效!
最后,我想知道是否需要指定具有播放列表 ID 的元素,但我不需要——我可以只给它一个 CSS ID 选择器:
我认为我的问题是,使用主 flowplayer 脚本,您可以解决不带
.
或#
限定符的占位符元素,例如$f("player")
;而不是$f("#player");
。但播放列表插件比较挑剔,你必须使用限定符。一个角色的所有痛苦!
OK, fixed.
Many of the examples use a class on the playlist container. In examples using a class, the playlist function is passed a CSS selector -- usually something like
playlist("div.gallery")
I changed my markup to use a class, changed the param to
playlist()
to a fully-qualified CSS selector, and it works!!!Now, I don't want to use a class-- I have a single playlist element, so I want to use an ID. I changed the markup back to an ID:
and changed the caller to use a CSS selector for IDs:
And that works too!
Finally, I wondered if I needed to specify the element that has the playlist ID, and I don't -- I can give it just a CSS ID selector:
I think my problem was that with the main flowplayer script, you can address the placeholder element without the
.
or#
qualifier, like$f("player")
; instead of$f("#player");
. But the Playlist plugin is more picky, and you have to use the qualifier.All that pain for a single character!