重置 FLVPlayback 组件以使用相同的源进行播放

发布于 2024-08-16 07:41:31 字数 735 浏览 2 评论 0原文

我使用相同的 FLVPlayback 组件在我正在构建的大型 Flash 网站中播放许多页面转换视频。在每次转换时,我都会使用 myFLVPlayback.source 设置组件的源,并在继续每个页面转换之前侦听 fl.video.VideoEvent.READY 事件。只要每对页面之间的过渡使用不同的视频,这种方法就可以正常工作。

不幸的是,当需要为两个连续转换调用相同的页面到页面转换视频时,我遇到了问题。当连续播放同一视频两次时,将组件的 source 属性设置为它已有的值似乎没有任何作用,这意味着我的 fl.video 监听器。 VideoEvent.READY 永远不会触发。我可以做一些黑客行为,比如将 source 设置为一个微小的、在其他地方从未使用过的 FLV,然后再将其设置为我实际用于转换的 FLV,作为“重置”组件的一种方式,但我想知道在这种情况下的最佳实践是什么(只要可以直面讨论 FLVPlaybackComponent 之类的最佳实践)。

我仔细阅读了 livedocs组件,但空手而归,在这个后期阶段手动使用 NetStream、NetConnection 和 Video 对象并不是真正的选择。

I'm using the same FLVPlayback component to play many page transition videos throughout a large flash site I'm building. On each transition, I'm setting the component's source using myFLVPlayback.source and listening for the fl.video.VideoEvent.READY event before proceeding with each page transition. This works fine as long as the transition between every pair of pages uses a different video.

Unfortunately, I'm running into a problem when the same page-to-page transition video needs to get invoked for two consecutive transitions. When playing the same video twice in a row, setting the source property of the component to the value it already has doesn't seem to do anything, meaning that my listeners for fl.video.VideoEvent.READY never fire. I could do something hackish like setting the source to a tiny, never-used-elsewhere FLV before setting it to the FLV that I'm actually using for the transition as a means of "resetting" the component, but I'd like to know what best practices are in a situation like this (insofar as best practices with something like the FLVPlaybackComponent can be discussed with a straight face).

I've perused the livedocs for the component but came up empty-handed, and manually using NetStream, NetConnection, and Video objects at this late stage isn't really an option.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

-黛色若梦 2024-08-23 07:41:31

我建议使用一个工具来检查您要播放的 URL 是否与之前的转换相同,如果是,则只需搜索(0)(即倒回视频)而不是重置源。重置源可能会强制视频重新播放(例如,如果浏览器缓存被禁用),但这可能不是您想要的。

if (myFlvPlayback.source == nextTransitionUrl) {
  myFlvPlayback.seek(0);
  startTransition();
}
else {
  myFlvPlayback.source = nextTransitionUrl;
  // The "ready" event will fire, and your event handler will start playback
}

查看 FLVPlayback.seek () 方法。

干杯

I would suggest having a harness that checks whether the URL you are about to play is the same as for the previous transition, and if it is, just seek(0) (i.e. rewind the video) instead of resetting source. Resetting the source might force the video to reloed (e.g. if browser cache is disabled) and that is probably not what you want anyway.

if (myFlvPlayback.source == nextTransitionUrl) {
  myFlvPlayback.seek(0);
  startTransition();
}
else {
  myFlvPlayback.source = nextTransitionUrl;
  // The "ready" event will fire, and your event handler will start playback
}

Have a look at the FLVPlayback.seek() method.

Cheers

孤者何惧 2024-08-23 07:41:31

看起来这个问题已经解决了一段时间,但我想无论如何我都会插话。要准确模拟您所描述的行为,您可以检查源是否 == 到下一个 URL,然后直接在 flvPlayback 实例上调用dispatchEvent。这样,它的行为就像 URL 不同时的情况一样,并且您必须编码的唯一手动干预只是检查 URL 是否为 ==。

Looks like this one has been solved for awhile, but I thought I'd chime in anyway. To exactly emulate the behavior you described, you could check to see if the source is == to the next URL, then just call dispatchEvent on the flvPlayback instance directly. That way it behaves like it would if the URL was different and the only manual intervention you've had to code in would be just checking if the URLs are ==.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文