Highlighted

How can I get low level access to netstream using OSMF?

Community Beginner ,
Aug 27, 2013

Copy link to clipboard

Copied

Hi

I'm trying to gain access to the low level netstream underneath the hood of OSMF so that I can access its netstream.info property for reading metrics.

I find that I am able to do this for MP4 videos but not for F4M dynamic streaming videos.

For MP4, I was successfully able to create a VideoElement that used a CustomNetLoader class which overrided the createNetStream method to return a netstream object.

However, for F4M, I have to use either the MediaFactory.createMediaElement(element) method or the F4MElement. The F4MElement does not allow a CustomNetLoader to be used and it seems to only accept a F4MLoader class.

Any advice on how I can access either the netstream object or the metrics of F4M videos?

Thanks

Views

2.7K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How can I get low level access to netstream using OSMF?

Community Beginner ,
Aug 27, 2013

Copy link to clipboard

Copied

Hi

I'm trying to gain access to the low level netstream underneath the hood of OSMF so that I can access its netstream.info property for reading metrics.

I find that I am able to do this for MP4 videos but not for F4M dynamic streaming videos.

For MP4, I was successfully able to create a VideoElement that used a CustomNetLoader class which overrided the createNetStream method to return a netstream object.

However, for F4M, I have to use either the MediaFactory.createMediaElement(element) method or the F4MElement. The F4MElement does not allow a CustomNetLoader to be used and it seems to only accept a F4MLoader class.

Any advice on how I can access either the netstream object or the metrics of F4M videos?

Thanks

Views

2.7K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 27, 2013 0
Community Beginner ,
Sep 03, 2013

Copy link to clipboard

Copied

ok, I finally got access to the direct netstream object - someone from Akamai gave me the answer.

Seeing how I wasn't able to find this answer anywhere on Google, I'm going to post the solution here as there's no way I would have known this solution without someone who knew how to get direct access to the netsteam object in OSMF.

There's a hidden class that won't show up in the code hint called org.osmf.net.NetStreamLoadTrait that you have to import.

1) First, your media player playing controlling your MediaElement has to listen for a LoadEvent.LOAD_STATE_CHANGE event after you load the MediaElement into the media player

mediaPlayer.addEventListener(LoadEvent.LOAD_STATE_CHANGE, onLoadStateChange);

2) Upon LoadEvent.LOAD_STATE_CHANGE, check for a org.osmf.traits.LoadState.READY - you can only access the NetStream object when it is LoadState.READY or the netstream object will return as null.

private function onLoadStateChange(e:LoadEvent)

{

                              if(e.loadState == LoadState.READY)

  {

  }

}

3) Once the LoadState.READY is true, you can create a datatype of NetStreamLoadTrait and type cast it from a Load trait:

private function onLoadStateChange(e:LoadEvent)

{

  if(e.loadState == LoadState.READY)

  {

     var nsLoadTrait:NetStreamLoadTrait = mediaPlayer.media.getTrait(MediaTraitType.LOAD) as NetStreamLoadTrait;

4) Once you successfully type cast the Media Load Trait from your media into NetStreamLoadTrait, you can access the property netstream from the NetStreamLoadTrait object.

private function onLoadStateChange(e:LoadEvent)

{

  if(e.loadState == LoadState.READY)

  {

     var nsLoadTrait:NetStreamLoadTrait = mediaPlayer.media.getTrait(MediaTraitType.LOAD) as NetStreamLoadTrait;

     var ns:NetStream = nsLoadTrait.netStream;

Hope this helps someone out there.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Sep 03, 2013 1
SHJeon LATEST
Community Beginner ,
Mar 02, 2015

Copy link to clipboard

Copied

Thank you for the information.

I was googling around and finally get to here.

What I'm trying to do is by using 1 stream and switch between two different players

( one for video object, and the other for StageVideo object).

Main purpose is that trying not to open stream twice, and keep main NativeWindow size as it is.

I could do it easily by using 'attachNetStream' method, but don't know whether this can be applied in OSMF as well.

Do you have any idea?

If possible to change between  video & StageVideo  on the fly, this is the best fit for my case, but I can't find the way.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Mar 02, 2015 0