我怎样才能从as3中的特定秒开始播放视频

发布于 2024-09-06 07:18:42 字数 765 浏览 4 评论 0原文

我对动作脚本 3 有疑问。我有一个 flv 视频,其总时间为 6 秒。我想用seekSeconds()从2秒开始。如果我在seekSeconds中写入大于6的值,它只会从头到尾播放视频。如果我写入小于6,它将不起作用。我可以在seekSeconds()中写入什么来从2秒开始播放视频?

function useParams()
{
var obj:Object = new Object();

var j;
for (j in this.myParams)
{
    if (j == "url")
    {
        src = this.myParams[j];
    }
    else if (j=="bas")
    {
        startTime = int(this.myParams[j]);
    }
    else
    {
        stopTime = int(this.myParams[j]);
    }

    txt.text +=  j + "  -  " + this.myParams[j];
}
//fk.source = src;
txt.text = String(startTime);

}

fk.addEventListener(VideoEvent.READY, bitti);
function bitti(eventObject:VideoEvent):void
{ 
//fk.play();
trace(fk.totalTime);
fk.seek(2);
trace(fk.playheadTime);
//trace(fk.playheadTime);
}

i have a problem about action script 3. i have a flv video and its totaltime is 6 seconds. i want to start it from 2. seconds with seekSeconds(). if i write bigger than 6 values in seekSeconds it will only play the video from head to end.İf i write smaller than 6 ,it won't work.what can i write in seekSeconds() to start the video from 2 seconds?

function useParams()
{
var obj:Object = new Object();

var j;
for (j in this.myParams)
{
    if (j == "url")
    {
        src = this.myParams[j];
    }
    else if (j=="bas")
    {
        startTime = int(this.myParams[j]);
    }
    else
    {
        stopTime = int(this.myParams[j]);
    }

    txt.text +=  j + "  -  " + this.myParams[j];
}
//fk.source = src;
txt.text = String(startTime);

}

fk.addEventListener(VideoEvent.READY, bitti);
function bitti(eventObject:VideoEvent):void
{ 
//fk.play();
trace(fk.totalTime);
fk.seek(2);
trace(fk.playheadTime);
//trace(fk.playheadTime);
}

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

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

发布评论

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

评论(1

权谋诡计 2024-09-13 07:18:42

根据 VideoPlayer,Event.READY 被调度:

当 FLV 文件加载并准备好显示时调度该事件。当您使用 play() 或 load() 方法加载新的 FLV 文件后第一次进入响应状态时,它就会启动。对于加载的每个 FLV 文件,它仅启动一次。

视频可能已准备就绪,但尚未缓冲到足够的量以供搜索。您可以将 bufferTime 更改为大于 2 的值,尽管我不确定这是否能保证 Event.READY 在您需要时被触发。另请注意“寻求渐进式下载”的属性:

对于渐进式下载,您只能寻找关键帧;因此,查找会将您带到指定时间之后的第一个关键帧的时间。

因此,请确保您设置的 bufferTime 足够提前超过 2 秒,以确保您传递了关键帧。

注意: VideoPlayer 和 NetStream 上都有一个 bufferTime,因此您可能需要调整其中之一或两者。

According to the documentation for VideoPlayer, Event.READY is dispatched:

Event dispatched when an FLV file is loaded and ready to display. It starts the first time you enter a responsive state after you load a new FLV file with the play() or load() method. It starts only once for each FLV file that is loaded.

It is possible the video is ready but it hasn't buffered to an adequate amount for seeking. You can change the bufferTime to a value greater than 2 although I am not certain that will guarantee Event.READY will get fired at the time you need. Also note the property of seek for progressive downloads:

For a progressive download, you can seek only to a keyframe; therefore, a seek takes you to the time of the first keyframe after the specified time.

So make sure you set a bufferTime that is adequately advanced passed 2 seconds to ensure you are passed a keyframe.

Note: there is a bufferTime on both a VideoPlayer and the NetStream so you may have to adjust one or the other or both.

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