检测 Flash 视频是否正在播放
我有一个NetConnection附加到NetStream,而后者又附加到视频。正如您所猜到的,这是一个视频播放器。我查看了所有三个类的公共属性,但找不到“isPlaying”属性 - 一个布尔值,可以告诉我视频当前正在运行(并且没有暂停、停止或损坏)。这样的财产存在吗?我已尝试以下方法,但不起作用:
- return this.video.currentFPS > 0。即使在 视频已暂停。
- 收听 NetStatusEvent 相应地更改和更新我自己的私有 isPlaying 属性。这 当您暂停视频时,NetStatus 不会改变。
I have a NetConnection attached to a NetStream, which is in turn attached to a Video. As you can guess, this is a video player. I've looked through the public properties of all three classes and could not find an "isPlaying" property - a boolean that would tell me video is currently running (and not paused, stopped, nor corrupted). Does such a property exist? I've tried the following but they don't work:
- return this.video.currentFPS > 0. The FPS is around 25 even when the
video is paused. - Listen on
NetStatusEvent change and update my own private isPlaying property accordingly. The
NetStatus does not change when you pause the video.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以查看
Video
的文档 和NetStream
元素,您会注意到它们都没有isPlaying
属性。您可以查看
VideoPlayer
类的代码(可能位于C:\Program Files\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\FLVPlayback\fl\video 如果您保留默认安装并使用 Windows)来查看如何管理播放状态的示例,只是不要复制代码,因为它是一团乱麻。
tl;dr:您必须自己管理视频的状态
You can see the docs for the
Video
andNetStream
elements, which you'll note neither have anisPlaying
property.You can check out the
VideoPlayer
class's code (probably atC:\Program Files\Adobe\Adobe Flash CS5\Common\Configuration\Component Source\ActionScript 3.0\FLVPlayback\fl\video
if you left the default install and use windows) to see an example of how to manage the play states, just don't copy the code as it's a scrambled mess.tl;dr: you have to manage the video's state yourself
使用
Timer
检查您的stream.time
并将其与之前的值进行比较。编写自定义togglePause()
函数并将状态存储在某些私有变量中也很有用use a
Timer
to check yourstream.time
and compare it to the previous value. writing a customtogglePause()
function and storing the state in some private variable'd also be useful