Highlighted

Use NetStream with MediaPlayerSprite in OSMF

New Here ,
Nov 26, 2012

Copy link to clipboard

Copied

Hi everybody,

Maybe what I'm trying is not possible or has no sense but is a requirement.

The thing is easy.

I've used OSMF for writing a video player. All works fine if I create a MediaPlayerSprite and set it's resource with URLResource. I can play any supported http or rmtp streaming video (flv, mp4, mpeg, etc...).

But now I need to use NetStream class for using some of its methods.

The times that I've used NetStream class were for streaming video with the flash Video object but now I want to use it with OSMF instead.

So my question is, is possible to use MediaPlayerSprite (and all of OSMF features) but also have the capability to use NetStream methods (like attachNetStream in particular) to control the video played in the MediaPlayerSprite object?

Yes that's it...Use attachNetStream with MediaPlayerSprite for handling the video.

Why? I'm using a subclass of NetStream provided by the client that works with flash Video object and of course not with MediaPlayerSprite and if I use any of the client's class methods, obviously I get a crash.

So how would you guys achieve that? Extending any class? Modifying OSMF build?

Thanks a lot in advance.

Views

3.2K

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

Use NetStream with MediaPlayerSprite in OSMF

New Here ,
Nov 26, 2012

Copy link to clipboard

Copied

Hi everybody,

Maybe what I'm trying is not possible or has no sense but is a requirement.

The thing is easy.

I've used OSMF for writing a video player. All works fine if I create a MediaPlayerSprite and set it's resource with URLResource. I can play any supported http or rmtp streaming video (flv, mp4, mpeg, etc...).

But now I need to use NetStream class for using some of its methods.

The times that I've used NetStream class were for streaming video with the flash Video object but now I want to use it with OSMF instead.

So my question is, is possible to use MediaPlayerSprite (and all of OSMF features) but also have the capability to use NetStream methods (like attachNetStream in particular) to control the video played in the MediaPlayerSprite object?

Yes that's it...Use attachNetStream with MediaPlayerSprite for handling the video.

Why? I'm using a subclass of NetStream provided by the client that works with flash Video object and of course not with MediaPlayerSprite and if I use any of the client's class methods, obviously I get a crash.

So how would you guys achieve that? Extending any class? Modifying OSMF build?

Thanks a lot in advance.

Views

3.2K

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
New Here ,
Oct 29, 2013

Copy link to clipboard

Copied

Hey this info might be a little late but here's how you get the netStream from the mediaPlayerSprite:

mediaPlayerSprite.mediaPlayer.addEventListener( MediaPlayerCapabilityChangeEvent.CAN_PLAY_CHANGE, capabilityHandler);

private function capabilityHandler(event:MediaPlayerCapabilityChangeEvent):void {

if(event.type == MediaPlayerCapabilityChangeEvent.CAN_PLAY_CHANGE){

     if (mediaPlayerSprite.media.hasTrait(MediaTraitType.LOAD)) {

          mediaPlayerSprite.media.getTrait(MediaTraitType.LOAD).addEventListener(LoadEvent.LOAD_STATE_CHANGE, netStreamLoadHandler);

     }

}

}

private function netStreamLoadHandler(e:LoadEvent):void {

mediaPlayerSprite.media.getTrait(MediaTraitType.LOAD).removeEventListener(LoadEvent.LOAD_STATE_CHANGE, netStreamLoadHandler);

     var loadTrait:Object = Object(mediaPlayerSprite.media.getTrait(MediaTraitType.LOAD));

     if(loadTrait != null && loadTrait.hasOwnProperty("netStream")) {

          var ns:NetStream =  loadTrait.netStream;

     }

}

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...