如何在 OSMF 中加载 ByteArray FLV?
我正在开发一个本地应用程序(它不是网站或没有任何相关内容),并且我现在有各种带有非常简单的加密方法的 FLV(就像在每个字节添加 10 一样)。
我可以在解密后使用 NetStream.appendBytes() 加载/播放它们,但这只有在我读取所有未流式传输的视频数据后才会发生。
我真正需要的是使用我已经构建的基于 OSMF 的播放器从远程 URL 流式传输这些视频,并在接收数据时进行解密。 我不知道 OSMF 如何处理 FLV,否则,我会尝试创建一个插件或类似的东西。 如果有人指出我如何处理这个问题,我将非常感激。
但如果有人帮助我找到一种使用 OSMF 加载本地文件的方法,传递 ByteArray 值而不是 url(如下),我会很高兴。或者甚至指导我创建一个 OSMF 插件来解决我的问题。
videoElement.resource = "video_url/video.flv";
这是我当前的代码,只是为了播放解码后的 FLV 字节数组
private function playBytes(bytes:ByteArray):void
{
// detecting it's header
if (bytes.readUTFBytes(3) != "FLV")
{
_text.appendText("\nFile \""+ file +"\" is not a FLV")
return void;
}
bytes.position = 0;
netConnection.connect(null);
netStream = new NetStream(netConnection);
netStream.client = { onMetaData:function(obj:Object):void { } }
video.attachNetStream(netStream);
addChild(video);
// put the NetStream class into Data Generation mode
netStream.play(null);
// before appending new bytes, reset the position to the beginning
netStream.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);
// append the FLV video bytes
netStream.appendBytes(bytes);
}
I'm working on a local application ( it's not a website or nothing related ) and I have various FLVs with a very simple encryptation method by now (just like adding 10 at each byte).
I can load/play them using NetStream.appendBytes() after decrypting, but that happens only after I read all video data it's not streamed.
What I really need is to stream those videos from a remote url, and decrypting while receiving data, using a OSMF based player that I already have built.
I'm lost on how OSMF deals with FLV, otherwise, I would try to create a plugin or something like.
I'd be very thankful if someone point me how to deal with that.
But I'd be happy if someone help me to find a way to load a local file using OSMF, passing a ByteArray value, instead of a url (below). Or even giving me directions to create a OSMF plugin to solve my problem.
videoElement.resource = "video_url/video.flv";
This is my current code just to play my decoded FLV byte array
private function playBytes(bytes:ByteArray):void
{
// detecting it's header
if (bytes.readUTFBytes(3) != "FLV")
{
_text.appendText("\nFile \""+ file +"\" is not a FLV")
return void;
}
bytes.position = 0;
netConnection.connect(null);
netStream = new NetStream(netConnection);
netStream.client = { onMetaData:function(obj:Object):void { } }
video.attachNetStream(netStream);
addChild(video);
// put the NetStream class into Data Generation mode
netStream.play(null);
// before appending new bytes, reset the position to the beginning
netStream.appendBytesAction(NetStreamAppendBytesAction.RESET_BEGIN);
// append the FLV video bytes
netStream.appendBytes(bytes);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有趣的帖子,我有兴趣看到答案。我自己看着类似的东西,虽然不是用流,但我发现了以下内容。
http://ntt.cc/2008/07 /15/bitsreader-read-bits-from-given-bytearray.html
传递字节数组后,您可以使用10位数组的bits.read(8)。也许这会让你走上正确的道路?否则,我认为您需要将其分开,并本质上做较小的部分来缓冲,以便连接所有缓冲的数据......
只是一个想法,
Interesting post, I'd be interested to see the answer. Looking at something similar myself, though not with a stream, I came across the following.
http://ntt.cc/2008/07/15/bitsreader-read-bits-from-given-bytearray.html
After passing the byte array you can use bits.read(8) of a 10 bit array. Perhaps this would send you down the correct path? Otherwise, I'm thinking you'd need to break it apart and essentially do smaller sections to buffer in order to concatenate all the buffered data...
Just a thought,