我已经将视频加载到FLVPlayback组件中,我正在寻找一种方法来获取到目前为止的总时间和时间并将它们输出到两个文本字段,因此最终结果看起来像“00: 12/00:50"
。现在我正在通过组件检查器定义视频,但我最终还希望通过actionscript来定义这一点。任何提示将不胜感激。
答案 0 :(得分:1)
你可以在这里找到时间: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html#playheadTime
在这里: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html#totalTime
还会定期触发事件,以便您可以轻松更新时间: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/video/FLVPlayback.html#event:playheadUpdate
编辑:更新了链接
答案 1 :(得分:1)
获得时间:
flvPlayer.playheadTime;// gives you the current videp position
格式化:
public static function formatTime(time:Number, detailLevel:uint = 2):String { var intTime:uint = Math.floor(time); var hours:uint = Math.floor(intTime/ 3600); var minutes:uint = (intTime - (hours*3600))/60; var seconds:uint = intTime - (hours*3600) - (minutes * 60); var hourString:String = detailLevel == HOURS ? hours + ":":""; var minuteString:String = detailLevel >= MINUTES ? ((detailLevel == HOURS && minutes = MINUTES)) ? "0":"") + seconds; return hourString + minuteString + secondString; }
答案 2 :(得分:-1)
我知道这是一个老问题 - 但我一直在寻找一些时间,但没有找到答案。
如果您正在使用FLVPlayback组件,那么您仍然可以使用MetadataEvent来获取嵌入在FLV / F4V文件中的元数据。 我通过AS3创建了一个FLVPlayback实例,监听了MedataEvent.METADATA_RECEIVED事件,然后访问了事件返回的info属性。在代码中,它看起来像这样:
package
{
import fl.video.FLVPlayback; // you will need to drag the component to the stage, then delete it. This puts some stuff in the library and now you can access the class
import fl.video.MetadataEvent;
import flash.display.MovieClip;
public class flvTest extends MovieClip
{
private var inputURL:String = "./test.flv"; // change this to the location of your FLV/F4V
private var player:FLVPlayback;
public function flvTest():void
{
player = new FLVPlayback();
// set x,y,width,height values if you want
player.autoRewind = true; // I use this so when you press stop, it goes to the first frame
player.load( inputURL ); // you can use load() or source=
player.addEventListener( MetadataEvent.METADATA_RECEIVED, getMetaFromFLV );
addChild( player );
}
private var getMetaFromFLV( metadataEvent:MetadataEvent = null ):void
{
trace( "FLV Duration: " + metadataEvent.info.duration );
}
}
}
你显然需要一些播放器控件等,但这个回复的关键是MetadataEvent部分。 事件返回的info属性包含嵌入FLV / F4V视频文件中的所有元数据,因此您可以获得许多其他值。
(许多其他搜索和帖子只解释了如何从NetStream中获取元数据,以及在连接到Flash Media Server时使用的类似内容 - 而在这里,我们正在访问本地文件并且只是想要文件所需的数据嵌入其中)。
我希望这有助于某人!