How to play FLV-formatted byteArray in OSMF?

I am developing a web application in flex that has a runtime recording function, having a snapshot of each frame, then encoding it in ByteArray to play the video.

I am currently using NetStream.appendBytes () to play ByteArray FLV. It works, but I just found out about OSMF and thought it was integrating it into my application.

Can flv byteArray be played in OSMF? An example of how this can be done will be completely different. thanks!

+4
source share
1 answer

Now I can play flv bytearrays in OSMF. I used to be able to play byteArray by creating a new class that extends netStream and overrides its playback method instead of using appendbytes. So I made OSMF use it. I did this by creating these classes: 1. ByteStreamElement - multimedia element 2. ByteStreamLoader - extends LoaderBase 3. ByteStreamLoadTrait - extends LoadTrait

overriding netstremas search / play method:

//manually dispatch seek event since we override seek() dispatchEvent(new NetStatusEvent(NetStatusEvent.NET_STATUS,false,false, {code:"NetStream.Play.Seek", level:"status"})); //look for byte position based on _seekTime value flvStream = _sfw.getFlvStream(false); _seekTime = parameters[1] * 1000; //netstream time in milliseconds _flvParser.parse(flvStream, false, flvTagSeeker); flvStream.position = _flvParserProcessed; //append flvtag from the new byte position to end of flv byteArray var tmp:ByteArray = new ByteArray(); flvStream.readBytes(tmp, 0, flvStream.bytesAvailable); _flvParserProcessed = 0; this.appendBytesAction(NetStreamAppendBytesAction.RESET_SEEK); appendBytes(tmp) 

And using it like this:

  mediaPlayerSprite = new MediaPlayerSprite(); addChild(mediaPlayerSprite); mediaPlayerSprite.media = new ByteStreamElement(); 

I'm really not sure though if this is the best way to do this. Not sure if I created new classes best, or if I had to write some kind of plugin for OSMF in order to use bytearrays for playback. And one more thing that I really need is to add to the player if necessary. That's why Im still not using this for average time. I stick with my custom "ByteStream player" until I figure it out.

+4
source

Source: https://habr.com/ru/post/1334795/


All Articles