1

I'm trying to emebed a simple OSMF player into my fex application. But it's not working. Here's my code :

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" applicationComplete="init()" >
<fx:Script>
    <![CDATA[
        import org.osmf.media.MediaPlayerSprite;
        import org.osmf.media.URLResource;

        protected function init():void{

            var sprite:MediaPlayerSprite = new MediaPlayerSprite();

            sprite.resource= new URLResource("http://mediapm.edgesuite.net/strobe/content/test/AFaerysTale_sylviaApostol_640_500_short.flv");
            container.addChild(sprite);
        }

    ]]>
</fx:Script>

<mx:UIComponent id="container" width="640" height="360"/>

I'm having a white screen when running the application

Thanks

Francisc
  • 77,430
  • 63
  • 180
  • 276
ismail
  • 11
  • 2
  • There's [one](http://www.brooksandrus.com/blog/2010/02/10/osmf-flex-example/) or [two](http://jodieorourke.com/view.php?id=150&blog=news) examples on how to do this that should help. – Paul Sweatte May 10 '12 at 22:47

1 Answers1

2

here's the pure AS for how to do it:

package  {
    import flash.display.Sprite;
    import org.osmf.media.MediaPlayerSprite;
    import org.osmf.media.URLResource;
    import org.osmf.media.DefaultMediaFactory;

    public class SimpleOSMFPlayer extends flash.display.Sprite {

    public static const PATH:String = "path/to/your/video.ext";

    public var playerSprite:MediaPlayerSprite;
    public var mediaFactory:DefaultMediaFactory;

        public function SimpleOSMFPlayer() {
            playerSprite = new MediaPlayerSprite();
            var resource:URLResource = new URLResource(PATH);
            mediaFactory = new DefaultMediaFactory();
            playerSprite.media = mediaFactory.createMediaElement(resource);
            addChild(playerSprite);
        }
    }       
}

for flex, add the playerSprite to your UIComponent container instead of the sprite on the last line.

kateiOS
  • 31
  • 3