我在stream.bytesTotal不可用的环境中创建视频播放器。我需要使用flv文件中编码的持续时间元数据来推断播放进度和时间显示等内容。
问题是当加载flv时,元数据(包括持续时间)无法在3次中被访问2次。这是迭代元数据对象的函数: -
public function onMetaDataHandler(metadataObj:Object):void {
for (var metadata:Object in metadataObj) {
if (metadata == "duration" ) {
_duration = metadataObj[metadata];
Debug.log('metadata _duration == ' + _duration );
playBackTimeText();
}
if (metadata == "width" ) {
video.width = metadataObj[metadata];
}
if (metadata == "height" ) {
video.height = metadataObj[metadata];
}
Debug.log(metadata + ": " + metadataObj[metadata], 0xffff00);
}
}
这是最好的方法,还是有办法重新加载元数据而无需重新加载flv?
答案 0 :(得分:0)
我不确定为什么但是看起来像将onMetaData函数设置为直接回调已经解决了这个问题。我不认为它很优雅,但它有效..
client = new Object();
client.onMetaData = function (metadataObj:Object):void {
for (var metadata:Object in metadataObj) {
if (metadata == "duration" ) {
_duration = metadataObj[metadata];
Debug.log('metadata _duration == ' + _duration );
playBackTimeText();
}
if (metadata == "width" ) {
video.width = metadataObj[metadata];
}
if (metadata == "height" ) {
video.height = metadataObj[metadata];
}
Debug.log(metadata + ": " + metadataObj[metadata], 0xffff00);
}
}
client.cuepoint = onCuePoint;
_stream.client = client;