AS3问题动态添加提示点到flv并寻找下一个提示点
我有一个 flvplayback 组件,正在向其加载视频。
为了模仿下一帧和上一帧的动作,我在加载的每一秒长度上添加提示点。
下一帧/上一帧函数在视频上实现了seekToNextNavCuePoint 和seekToPrevNavCuePoint
。
但它并没有按照我预期的方式工作。
这是实际的类文件。您可以直接使用包含库中播放暂停停止按钮实例的 fla 文件对其进行编译...此外,您还需要一些示例 flv 文件。
package
{
/*
The fla file contains buttons in the library;
*/
import flash.events.*;
import flash.display.*;
import fl.video.*;
public class testPlayer extends MovieClip
{
private var video1:FLVPlayback;
private var play_btn:PlayButton;
private var pause_btn:PauseButton;
private var stop_btn:StopButton;
private var nextFrame_btn:ForwardButton;
private var previousFrame_btn:ForwardButton;
public function testPlayer()
{
// constructor code
addEventListener(Event.ADDED_TO_STAGE,onAdded);
}
private function onAdded(event:Event)
{
setPlayer();
setPath();
setButtons();
}
private function setPlayer()
{
video1 = new FLVPlayback ;
this.addChild(video1);
video1.x = 50;
video1.y = 50;
}
private function setPath()
{
video1.addEventListener(VideoEvent.READY, flvPlayback_ready);
video1.addEventListener(MetadataEvent.CUE_POINT, flvPlayback_cuePoint);
// here you can give any flv you have and its total time
video1.load("test.flv",3600,false);
}
private function flvPlayback_ready(evt:VideoEvent):void
{
var num:Number = video1.totalTime;
for (var i:int=0; i<num; i++)
{
video1.addASCuePoint(i, "cuePoint"+String(i));
}
this.removeEventListener(VideoEvent.READY, flvPlayback_ready);
}
private function flvPlayback_cuePoint(evt:MetadataEvent):void
{
trace("CUE POINT!!!");
trace("\t", "name:", evt.info.name);// name: cuePoint1
trace("\t", "time:", evt.info.time);// time: 1
trace("\t", "type:", evt.info.type);// type: actionscript
}
private function setButtons()
{
play_btn=new PlayButton();
pause_btn=new PauseButton();
stop_btn=new StopButton();
nextFrame_btn=new ForwardButton();
previousFrame_btn=new ForwardButton();
play_btn.addEventListener(MouseEvent.CLICK,onPlay);
pause_btn.addEventListener(MouseEvent.CLICK,onPause);
stop_btn.addEventListener(MouseEvent.CLICK,onStop);
nextFrame_btn.addEventListener(MouseEvent.CLICK,onNextFrame);
previousFrame_btn.addEventListener(MouseEvent.CLICK,onPreviousFrame);
play_btn.x = 50;
play_btn.y = 350;
previousFrame_btn.x = 125;
previousFrame_btn.y = 350;
previousFrame_btn.scaleX *= -1;
nextFrame_btn.x = 150;
nextFrame_btn.y = 350;
pause_btn.x = 200;
pause_btn.y = 350;
stop_btn.x = 250;
stop_btn.y = 350;
addChild(play_btn);
addChild(pause_btn);
addChild(stop_btn);
addChild(previousFrame_btn);
addChild(nextFrame_btn);
}
private function onPlay(event:MouseEvent)
{
video1.play();
}
private function onPause(event:MouseEvent)
{
video1.pause();
}
private function onStop(event:MouseEvent)
{
video1.stop();
}
private function onNextFrame(event:Event)
{
if (video1.playing)
{
//video1.pause();
}
// this is not working the way i expected it to
video1.seekToNextNavCuePoint();
}
private function onPreviousFrame(event:Event)
{
if (video1.playing)
{
//video1.pause();
}
// this is not working the way i expected it to
video1.seekToPrevNavCuePoint();
}
}
}
我在这里缺少什么?只需运行它而不调用下一帧/上一帧函数即可显示提示点根据 flvPlayback_cuePoint 函数每秒被激活。
update:
当我单击 previousFrame 按钮时,无论当前提示点在哪里,帧都会切换到cuepoint1。当我单击 nextFrame 按钮时,提示点和显示似乎会更改为下一个,但单击几次后不久,提示点会更改为 1 并且视频从头开始。
问题 1: 使用 addASCuePoint() 在 ActionScript 3.0 中沿加载的影片长度动态添加提示点的正确方法是什么
问题 2: 我们可以以 33ms 的间隔添加提示点吗? 可以正确地寻找到吗?
问题 3:上面的代码有什么问题?
更新: 添加赏金:解决问题并解答 3 个问题
更新:
经过多次不成功的尝试上述方法并尝试了 Trevor 的建议。 我通过seek()方法获得了该功能,但精度相当低。
package
{
/*
The fla file contains buttons in the library;
*/
import flash.events.*;
import flash.display.*;
import fl.video.*;
public class testPlayer extends MovieClip
{
private var video1:FLVPlayback;
private var play_btn:PlayButton;
private var pause_btn:PauseButton;
private var stop_btn:StopButton;
private var nextFrame_btn:ForwardButton;
private var previousFrame_btn:ForwardButton;
private var playHeadTime:Number;
private var cue:Object;
public function testPlayer()
{
addEventListener(Event.ADDED_TO_STAGE,onAdded);
}
private function onAdded(event:Event)
{
setPlayer();
setPath();
setButtons();
playHeadTime = 0;
}
private function setPlayer()
{
video1 = new FLVPlayback ;
this.addChild(video1);
video1.x = 50;
video1.y = 50;
}
private function setPath()
{
video1.playheadUpdateInterval = 50;
video1.seekToPrevOffset = 0.01;
video1.addEventListener(VideoEvent.READY, flvPlayback_ready);
video1.addEventListener(MetadataEvent.CUE_POINT, flvPlayback_cuePoint);
video1.load("test.flv",3600,false);
}
private function flvPlayback_ready(evt:VideoEvent):void
{
// changing this loop to add more cue points causes the program to hang.
for (var i:int=0; i<video1.totalTime; i++)
{
cue= new Object();
cue.time = i;
cue.type = "navigation";// this does not seem to get set the type
cue.name = "cuePoint" + String(i);
video1.addASCuePoint(cue,cue.name);
}
video1.removeEventListener(VideoEvent.READY, flvPlayback_ready);
}
private function flvPlayback_cuePoint(evt:MetadataEvent):void
{
trace("CUE POINT!!!");
trace("\t", "name:", evt.info.name);// name: cuePoint1
trace("\t", "time:", evt.info.time ," playhead time :",String(Math.round(video1.playheadTime)));// time: 1
trace("\t", "====type:", evt.info.type);// traces actionscript instead of navigation
}
private function setButtons()
{
play_btn=new PlayButton();
pause_btn=new PauseButton();
stop_btn=new StopButton();
nextFrame_btn=new ForwardButton();
previousFrame_btn=new ForwardButton();
play_btn.addEventListener(MouseEvent.CLICK,onPlay);
pause_btn.addEventListener(MouseEvent.CLICK,onPause);
stop_btn.addEventListener(MouseEvent.CLICK,onStop);
nextFrame_btn.addEventListener(MouseEvent.CLICK,onNextFrame);
previousFrame_btn.addEventListener(MouseEvent.CLICK,onPreviousFrame);
play_btn.x = 50;
play_btn.y = 350;
previousFrame_btn.x = 125;
previousFrame_btn.y = 350;
previousFrame_btn.scaleX *= -1;
nextFrame_btn.x = 150;
nextFrame_btn.y = 350;
pause_btn.x = 200;
pause_btn.y = 350;
stop_btn.x = 250;
stop_btn.y = 350;
addChild(play_btn);
addChild(pause_btn);
addChild(stop_btn);
addChild(previousFrame_btn);
addChild(nextFrame_btn);
}
private function onPlay(event:MouseEvent)
{
video1.play();
}
private function onPause(event:MouseEvent)
{
video1.pause();
}
private function onStop(event:MouseEvent)
{
video1.stop();
}
private function onNextFrame(event:Event)
{
if (video1.playing)
{
video1.stop();
}
trace("Calling nextFrame :::",playHeadTime);
video1.seek(playHeadTime);
playHeadTime += 1;
}
private function onPreviousFrame(event:Event)
{
if (video1.playing)
{
video1.stop();
}
trace("Calling prevFrame ::::",playHeadTime);
video1.seek(playHeadTime);
playHeadTime -= 1;
}
}
}
以下跟踪的输出如下所示。问题是下一个和上一个函数不断跳过提示点,并且似乎在某些提示点不起作用。下面的痕迹应该可以清晰地显示出来。
Calling nextFrame ::: 0
CUE POINT!!!
name: cuePoint0
time: 0 playhead time : 0
====type: actionscript
Calling nextFrame ::: 1
CUE POINT!!!
name: cuePoint2
time: 2 playhead time : 2
====type: actionscript
Calling nextFrame ::: 2
Calling nextFrame ::: 3
CUE POINT!!!
name: cuePoint4
time: 4 playhead time : 4
====type: actionscript
Calling prevFrame :::: 4
Calling prevFrame :::: 3
Calling prevFrame :::: 2
CUE POINT!!!
name: cuePoint2
time: 2 playhead time : 2
====type: actionscript
编辑:
- 问题 1:我们如何在连续的提示点上触发 MetadataEvent.CUE_POINT,即不跳过提示点。
- 问题 2:当每个提示点每隔 100 毫秒时,我们如何触发 MetadataEvent.CUE_POINT 事件。
I have a flvplayback component onto which I am loading a video.
To mimic next frame and previous frame actions I am adding cue points to the loaded for every second of its length.
The next frame /previous frame functions implement seekToNextNavCuePoint and seekToPrevNavCuePoint
on the video.
But its not working the way I expected it to.
Here is the actual class file. You can directly compile it with an fla file containing button instances in the library for play pause stop... Also you would need some sample flv file.
package
{
/*
The fla file contains buttons in the library;
*/
import flash.events.*;
import flash.display.*;
import fl.video.*;
public class testPlayer extends MovieClip
{
private var video1:FLVPlayback;
private var play_btn:PlayButton;
private var pause_btn:PauseButton;
private var stop_btn:StopButton;
private var nextFrame_btn:ForwardButton;
private var previousFrame_btn:ForwardButton;
public function testPlayer()
{
// constructor code
addEventListener(Event.ADDED_TO_STAGE,onAdded);
}
private function onAdded(event:Event)
{
setPlayer();
setPath();
setButtons();
}
private function setPlayer()
{
video1 = new FLVPlayback ;
this.addChild(video1);
video1.x = 50;
video1.y = 50;
}
private function setPath()
{
video1.addEventListener(VideoEvent.READY, flvPlayback_ready);
video1.addEventListener(MetadataEvent.CUE_POINT, flvPlayback_cuePoint);
// here you can give any flv you have and its total time
video1.load("test.flv",3600,false);
}
private function flvPlayback_ready(evt:VideoEvent):void
{
var num:Number = video1.totalTime;
for (var i:int=0; i<num; i++)
{
video1.addASCuePoint(i, "cuePoint"+String(i));
}
this.removeEventListener(VideoEvent.READY, flvPlayback_ready);
}
private function flvPlayback_cuePoint(evt:MetadataEvent):void
{
trace("CUE POINT!!!");
trace("\t", "name:", evt.info.name);// name: cuePoint1
trace("\t", "time:", evt.info.time);// time: 1
trace("\t", "type:", evt.info.type);// type: actionscript
}
private function setButtons()
{
play_btn=new PlayButton();
pause_btn=new PauseButton();
stop_btn=new StopButton();
nextFrame_btn=new ForwardButton();
previousFrame_btn=new ForwardButton();
play_btn.addEventListener(MouseEvent.CLICK,onPlay);
pause_btn.addEventListener(MouseEvent.CLICK,onPause);
stop_btn.addEventListener(MouseEvent.CLICK,onStop);
nextFrame_btn.addEventListener(MouseEvent.CLICK,onNextFrame);
previousFrame_btn.addEventListener(MouseEvent.CLICK,onPreviousFrame);
play_btn.x = 50;
play_btn.y = 350;
previousFrame_btn.x = 125;
previousFrame_btn.y = 350;
previousFrame_btn.scaleX *= -1;
nextFrame_btn.x = 150;
nextFrame_btn.y = 350;
pause_btn.x = 200;
pause_btn.y = 350;
stop_btn.x = 250;
stop_btn.y = 350;
addChild(play_btn);
addChild(pause_btn);
addChild(stop_btn);
addChild(previousFrame_btn);
addChild(nextFrame_btn);
}
private function onPlay(event:MouseEvent)
{
video1.play();
}
private function onPause(event:MouseEvent)
{
video1.pause();
}
private function onStop(event:MouseEvent)
{
video1.stop();
}
private function onNextFrame(event:Event)
{
if (video1.playing)
{
//video1.pause();
}
// this is not working the way i expected it to
video1.seekToNextNavCuePoint();
}
private function onPreviousFrame(event:Event)
{
if (video1.playing)
{
//video1.pause();
}
// this is not working the way i expected it to
video1.seekToPrevNavCuePoint();
}
}
}
What am I missing here? Just running it without invoking next/prev frame functions shows that the cue points being activated for every second as per the flvPlayback_cuePoint function.
update:
When I click the previousFrame button the frame shifts to cuepoint1 , irrespective of where the present cuepoint is. When I click the nextFrame button, the cue point and the display seemingly changes to next, but soon after a few clicks the cue point changes to 1 and the video starts from the beginning.
Question 1 : What is the Correct way to dynamically add Cue points in ActionScript 3.0 along the length of the loaded movie using addASCuePoint()
Question 2 : Can We add cue points with at intervals of 33ms, at which we
can properly seek to?Question 3: What is wrong in the above code?
update:
Adding a bounty : To solve the problem and answers to The 3 questions
update:
After much unsuccessful trials with the above methods and trying out suggestions by Trevor.
I got the functionality working through seek() method but with considerable lack of precision .
package
{
/*
The fla file contains buttons in the library;
*/
import flash.events.*;
import flash.display.*;
import fl.video.*;
public class testPlayer extends MovieClip
{
private var video1:FLVPlayback;
private var play_btn:PlayButton;
private var pause_btn:PauseButton;
private var stop_btn:StopButton;
private var nextFrame_btn:ForwardButton;
private var previousFrame_btn:ForwardButton;
private var playHeadTime:Number;
private var cue:Object;
public function testPlayer()
{
addEventListener(Event.ADDED_TO_STAGE,onAdded);
}
private function onAdded(event:Event)
{
setPlayer();
setPath();
setButtons();
playHeadTime = 0;
}
private function setPlayer()
{
video1 = new FLVPlayback ;
this.addChild(video1);
video1.x = 50;
video1.y = 50;
}
private function setPath()
{
video1.playheadUpdateInterval = 50;
video1.seekToPrevOffset = 0.01;
video1.addEventListener(VideoEvent.READY, flvPlayback_ready);
video1.addEventListener(MetadataEvent.CUE_POINT, flvPlayback_cuePoint);
video1.load("test.flv",3600,false);
}
private function flvPlayback_ready(evt:VideoEvent):void
{
// changing this loop to add more cue points causes the program to hang.
for (var i:int=0; i<video1.totalTime; i++)
{
cue= new Object();
cue.time = i;
cue.type = "navigation";// this does not seem to get set the type
cue.name = "cuePoint" + String(i);
video1.addASCuePoint(cue,cue.name);
}
video1.removeEventListener(VideoEvent.READY, flvPlayback_ready);
}
private function flvPlayback_cuePoint(evt:MetadataEvent):void
{
trace("CUE POINT!!!");
trace("\t", "name:", evt.info.name);// name: cuePoint1
trace("\t", "time:", evt.info.time ," playhead time :",String(Math.round(video1.playheadTime)));// time: 1
trace("\t", "====type:", evt.info.type);// traces actionscript instead of navigation
}
private function setButtons()
{
play_btn=new PlayButton();
pause_btn=new PauseButton();
stop_btn=new StopButton();
nextFrame_btn=new ForwardButton();
previousFrame_btn=new ForwardButton();
play_btn.addEventListener(MouseEvent.CLICK,onPlay);
pause_btn.addEventListener(MouseEvent.CLICK,onPause);
stop_btn.addEventListener(MouseEvent.CLICK,onStop);
nextFrame_btn.addEventListener(MouseEvent.CLICK,onNextFrame);
previousFrame_btn.addEventListener(MouseEvent.CLICK,onPreviousFrame);
play_btn.x = 50;
play_btn.y = 350;
previousFrame_btn.x = 125;
previousFrame_btn.y = 350;
previousFrame_btn.scaleX *= -1;
nextFrame_btn.x = 150;
nextFrame_btn.y = 350;
pause_btn.x = 200;
pause_btn.y = 350;
stop_btn.x = 250;
stop_btn.y = 350;
addChild(play_btn);
addChild(pause_btn);
addChild(stop_btn);
addChild(previousFrame_btn);
addChild(nextFrame_btn);
}
private function onPlay(event:MouseEvent)
{
video1.play();
}
private function onPause(event:MouseEvent)
{
video1.pause();
}
private function onStop(event:MouseEvent)
{
video1.stop();
}
private function onNextFrame(event:Event)
{
if (video1.playing)
{
video1.stop();
}
trace("Calling nextFrame :::",playHeadTime);
video1.seek(playHeadTime);
playHeadTime += 1;
}
private function onPreviousFrame(event:Event)
{
if (video1.playing)
{
video1.stop();
}
trace("Calling prevFrame ::::",playHeadTime);
video1.seek(playHeadTime);
playHeadTime -= 1;
}
}
}
The output for the following traces out like given below. The problem is the next and previous functions keep skipping cue points and don't seem to work at certain cue points. the trace below should give the clear picture.
Calling nextFrame ::: 0
CUE POINT!!!
name: cuePoint0
time: 0 playhead time : 0
====type: actionscript
Calling nextFrame ::: 1
CUE POINT!!!
name: cuePoint2
time: 2 playhead time : 2
====type: actionscript
Calling nextFrame ::: 2
Calling nextFrame ::: 3
CUE POINT!!!
name: cuePoint4
time: 4 playhead time : 4
====type: actionscript
Calling prevFrame :::: 4
Calling prevFrame :::: 3
Calling prevFrame :::: 2
CUE POINT!!!
name: cuePoint2
time: 2 playhead time : 2
====type: actionscript
Edit:
- Question 1 : How can we trigger the MetadataEvent.CUE_POINT on successive cue points i.e without it skipping a cue point.
- Question 2 : How cab we trigger the MetadataEvent.CUE_POINT event at each cue point when they are lets say at 100 ms intervals.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
第三组问题
*我们如何在连续的提示点上触发 MetadataEvent.CUE_POINT ,即不跳过提示点。*
*当它们在每个提示点上时,我们如何触发 MetadataEvent.CUE_POINT 事件假设间隔为 100 毫秒。*
这可能看起来很奇怪,但您不能保证您会收到特定的提示点事件。提示点事件不会被整理或排队。由于 FLV 容器和 swf 之间的帧速率不同,某些事件将被丢弃。如果您包含的 swf 文件位于“帧之间”,则几乎肯定会错过 flv 上的提示点。如果提示点相距 100 毫秒,并且您对 swf 使用标准 24fps。我估计您可能会丢失每 5 个提示点事件中至少 1 个。这类似于闪存处理许多事情(例如垃圾收集)的方式,它会尽力而为,但如果“帧”需要继续移动,它将停止底层进程的执行。即使您同步帧速率和提示点间隔,您仍然偶尔会错过事件。
现在……话虽如此。您可以通过不使用提示点来完成您想要的事情。只需监视 playheadUpdate 事件并随着播放头时间的增加调度您需要的任意数量的事件。例如...如果您希望每 100 毫秒发生一次事件,并且自上次以来播放头已移动 223 毫秒,则分派 2 个事件。如果仅移动了 30 毫秒,则不要调度任何事件...
第二组问题
问题 1:为什么搜索会跳过提示点并且不适用于每次调用
只能寻找视频中的关键帧。您可以在任意位置定义提示点,但搜索将始终搜索下一个最近的关键帧。这就是为什么您会看到您所看到的行为。
摘自 livedocs 上的 FLVPlayback.seek()
问题 2:如何在 Mills 第二个提示点上实现此功能
没有人喜欢听这个,但您可能不会能够执行此操作除非您能够修改 flv 并在这些点插入关键帧。不过我猜测如果你能做到这一点,你就不需要动态添加提示点。
问题 3:如何在毫秒范围内动态添加提示点而不破坏程序。
所以这是我有点分歧的地方,建议您根本不要使用提示点。您似乎正在尝试在播放 flv 和/或尝试寻找 flv 中的给定位置时让事件在给定的时间间隔内触发。
寻找 flv 中的任何位置不需要提示点。只需将时间(以毫秒为单位)传递给搜索命令即可。 (如上所述,您将只能寻找关键帧。)
有一种更简单的方法可以从您想要设置 playheadUpdateInterval 的 flvplayback 中获取间隔上的事件并添加playheadUpdate 事件的侦听器。此事件包括发送时的播放头时间。
在您的情况下,只需将间隔设置为 33 毫秒,然后在附加到事件的侦听器中执行您想要执行的任何操作。
所有这一切需要记住的一件事是,FLV 播放是在单独的“时间线”上进行的,其帧速率与 swf 文件不同。因为两者之间的时间安排几乎永远不会准确。
第一组问题
问题 1:使用 addASCuePoint() 在 ActionScript 3.0 中沿着加载的影片长度动态添加提示点的正确方法是什么
更正上面的for循环看起来不错
问题2:我们可以以33ms的间隔添加提示点,以便我们可以正确地寻找吗?
是的,您可以在任何时间间隔或您想要的位置添加提示点,但这与关键帧存在的位置无关。
问题3:上面的代码有什么问题?
坦率地说,这是对提示点的滥用。他们确实不是您要寻找的。
Third Group of Question
*How can we trigger the MetadataEvent.CUE_POINT on successive cue points i.e without it skipping a cue point.*
*How cab we trigger the MetadataEvent.CUE_POINT event at each cue point when they are lets say at 100 ms intervals.*
It may seem strange, but you cannot guarantee that you will receive a specific cue point event. Cue point events are not marshaled or queued. Since the frame rates between the FLV container and the swf are different some events will just get thrown out. If your containing swf file is "between frames" it will almost certainly miss cuepoints on the flv. If the cuepoints are 100ms apart and you are using the standard 24fps for the swf. I estimate that you could expect to loose at least 1 out of every 5 cue point events. This is similar to the way flash handles a number of things (like garbage collection) it does the best it can but it will halt execution of underlying process if the 'frame' needs to move on. Even if you sync the frame rate and the cue point interval you will still miss events occasionally.
Now... all that being said. You could accomplish what you want by not using cue points. Just monitor the playheadUpdate event and dispatch however many events you need as the playhead time increases. For example... if you want the event once every 100 ms and the playhead has moved 223ms since the last time, then dispatch 2 events. If it's only moved 30ms don't dispatch any events....
Second Group of Questions
Question 1 : Why is the seek skipping cue points and not working on every call
You will only be able to seek to key frames in your video. You can define cue points wherever you like however seek will always seek to the next nearest key frame. This is why you see the behavior you are seeing.
excerpt from FLVPlayback.seek() on livedocs
Question 2 : How to get this working at mills second cue points
No one likes to hear this, but you probably won't be able to do this unless you are able to modify the flv and have a key frame inserted there at those points. However I am guessing that if you could do this you wouldn't need to dynamically add the cue points.
Question 3 : How do i add cue points dynamically in millisecond range without breaking the program.
So here is where I diverge a litle bit and recommend that you not use cue points at all. It seems that you are trying to get an event to fire on given interval while playing the flv and/or trying to seek to given positions in an flv.
Seeking to any position in an flv does not require cue points. Just pass the time in milliseconds to the seek command. (With the caveat as mentioned above that you will only be able to seek to key frames.)
There is an easier way to get events on an interval from the flvplayback you want to set the playheadUpdateInterval and add a listener to the playheadUpdate event. This event includes the play head time at the moment it was dispatched.
In your case just set the interval to 33 ms, and do whatever it is you want to do in a listener attached to the event.
One thing to keep in mind with all this is that the FLV playback is occurring on a separate "timeline" with a different frame rate than your swf file. Because of this timing between the two will almost never be exact.
First Group of Questions
Question 1 : What is the Correct way to dynamically add Cue points in ActionScript 3.0 along the length of the loaded movie using addASCuePoint()
correction the for loop you have above looks fine
Question 2 : Can We add cue points with at intervals of 33ms, at which we can properly seek to?
Yes you can add cue points at any interval or place you would like, but this has no bearing on where keyframes exist.
Question 3: What is wrong in the above code?
Frankly it's an abuse of cue points. They really aren't what you are looking for.
尝试在每秒导出 flv 时向其添加关键帧,因为如果它是渐进式的,您只能寻找视频中的关键帧。流式传输时,您可以转到精确时间。
Q1.
video1.addASCuePoint(i, "cuePoint"+String(i));
可以正常工作,我唯一担心的是 i 的初始值为 0,我不确定这个值是否会被存储或触发......但它可能是。Q2。是的,如果视频是流式传输或渐进式且有关键帧并且帧速率为 30fps 或更高。为了每 33 毫秒就有一个提示点,您的视频需要为 30 fps。如果您可以接受每 40 毫秒一次的提示点,那么 25 fps 就可以了。帧速率在编码时设置,通常与源保持相同。
Q3。可以尝试一些事情:
尝试将
seekToPrevOffset()
设置为较低的值,例如。 0.1(或者如果您计划在帧上放置提示点则更小的值),默认设置为 1,这意味着它可能会跳过提示点。还可以尝试将
playheadUpdateInterval
从 250 降低到 50,这可能有助于查找。如果频繁地每 30 毫秒查找一次,则必须将其设置得更低。如果视频是渐进式的,请勿搜索超出已加载内容的内容,否则播放头将跳回到开头。
在上一个搜索命令完成之前,不允许用户单击下一步,因为
seekToNextNavCuePoint()
基于当前播放头时间。或者,您可以将一个值传递到seekToNextNavCuePoint(myCheckForwardFromHereVar)
中,以便用户可以多次按“next”,而无需等待搜索命令完成。如果您想获得更大的控制权,可以跟踪您在视频中的位置,然后使用
seekToNavCuePoint()
创建您自己的seekToNextNavCuePoint
和seekToNextPrevCuePoint< /代码> 功能。例如。
seekToNavCuePoint("cuePoint" + String(Math.floor(playheadTime)));
eekToNavCuePoint("cuePoint" + String(Math.floor(playheadTime)+1));
Try adding key frames to the flv when you export it at every second, because if it is progressive you can only seek to key frames in your video. When streaming you can go to the precise time.
Q1.
video1.addASCuePoint(i, "cuePoint"+String(i));
will work fine, my only slight concern with this is the initial value of i being 0, I am not sure if this value will be stored or triggered... but it might be.Q2. Yes, if the video is streaming or if it is progressive and there is a key frame there and the frame rate is 30fps or higher. In order to have cuepoints every 33ms, your video will need to be 30fps. If you could live with cuepoints every 40ms it would be ok to have 25fps. The frame rate is set at the time of encoding and usually just left as the same as the source.
Q3. A few things to try:
Try setting
seekToPrevOffset()
to a lower value eg. 0.1 (or something a lot smaller if you plan on putting cuepoints on frames), be default it is set to 1 which means it maybe skipping over cue points.Also try lowering the
playheadUpdateInterval
to maybe 50 from 250, this may help with the seeking. You will have to put it even lower if frequently seeking every 30ms.If the video is progressive, don't seek further than what has loaded, otherwise the playhead will jump back to the start.
Don't allow the user to click next until the previous seek command has been completed as
seekToNextNavCuePoint()
is based on the current play head time. Alternatively you could pass a value intoseekToNextNavCuePoint(myCheckForwardFromHereVar)
so that the user could press next multiple times without waiting for the seek command to complete.If you wanted to have even greater control you could keep track of where you are in the video and then use
seekToNavCuePoint()
to create your ownseekToNextNavCuePoint
andseekToNextPrevCuePoint
functions. eg.seekToNavCuePoint("cuePoint" + String(Math.floor(playheadTime)));
seekToNavCuePoint("cuePoint" + String(Math.floor(playheadTime)+1));
问题 1:使用 addASCuePoint() 在 ActionScript 3.0 中沿着加载影片的长度动态添加提示点的正确方法是什么
问题2:我们可以以33ms的间隔添加提示点,以便我们可以正确地寻找吗?
请参阅问题 1 的答案,请确保不要超过 flv 的长度
如果您在 33 毫秒时更改视觉项目,您会让人们的眼睛流血
问题3:上面的代码有什么问题?
您从未定义过提示点的位置和作用。你能举例说明你在每个提示点会做什么吗?
当您提供更多信息时,我会编辑此内容。
Question 1 : What is the Correct way to dynamically add Cue points in ActionScript 3.0 along the length of the loaded movie using addASCuePoint()
Question 2 : Can We add cue points with at intervals of 33ms, at which we can properly seek to?
See answer to question 1 be sure not to go past the length of the flv
If you are changing visual items at 33ms you will make peoples eyes bleed
Question 3: What is wrong in the above code?
You never defined where and what the cue points do. Can you give an example of whatyou will do at each cue point?
I will edit this when you give more info.