问题描述
我正在尝试使用 NetStream 从 byteArray 播放.请参阅this了解我在说什么.
I am trying to use NetStream to play from a byteArray. Please see this for what I am talking about.
我可以用它来播放视频.但是现在我需要能够看到特定的秒数.我无法做到这一点.如果我通过 bytearray 我知道我可以根据需要获取元数据和关键帧以及每个关键帧所在位置的偏移量(以字节为单位).然而,没有办法寻求特定的偏移量.它仅支持以秒为单位的查找,并且似乎不适用于 byteArray.
I am able to get this to play the video. However now I need to be able to see to a particular second. I am not able to do this. If I go through the bytearray I know I can get the metadata and the keyframes as required and the offset ( in bytes) as to where each keyframe is at. However there is no way to seek to a particular offset. It only supports seek in seconds and that doesn't seem to work on the byteArray.
我该怎么做?
推荐答案
I got I work:
I got I worked:
// onmetadata function get all timestamp and corresponding fileposition..
function onMetaData(infoObject: Object): void {
for (var propName: String in infoObject) {
if (propName == "keyframes") {
var kfObject: Object = infoObject[propName];
var timeArr: Array = kfObject["times"];
var byteArr: Array = kfObject["filepositions"];
for (var i: int = 0;i < timeArr.length;i++) {
var tagPos: int = byteArr[i]; //Read the tag size;
var timestamp: Number = timeArr[i]; //read the timestamp;
tags.push({
timestamp: timestamp,
tagPos: tagPos
});
}
}
// onseek click get approximate timestamp and its fileposition
protected
function seek_click(seektime: Number): void {
var cTime: Number = 0;
var pTime: Number = 0;
for (var i: int = 1;i < tags.length;i++) {
cTime = tags[i].timestamp;
pTime = tags[i - 1].timestamp;
if (pTime < seektime) {
if (seektime < cTime) {
seekPos = tags[i - 1].tagPos;
stream.seek(pTime);
break;
}
}
}
}
/// append bytes on seekposition
private
function netStatusHandler(event: NetStatusEvent): void {
switch (event.info.code) {
case "NetStream.Seek.Notify":
stream.appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK);
totalByteArray.position = seekPos;
var bytes: ByteArray = new ByteArray();
totalByteArray.readBytes(bytes);
stream.appendBytes(bytes);
stream.resume();
break;
}
}
这篇关于在 AS3 中使用 NetStream 进行视频播放时,我使用 appendBytes 时如何查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!