3 Replies Latest reply on Oct 16, 2009 1:26 AM by Vincent Nabet

    Simple flex example

    Vincent Nabet

      I searh a basic flex example like the lesson 1 of this article http://www.adobe.com/devnet/flash/articles/video_osmf.html

       

      this code in a creationComplete handler of my application:

      player = new MediaPlayer();

      player.source = new VideoElement( new NetLoader(), new URLResource( new URL ( "jkennedy.flv" ) ) );

      addChild(player.view);

       

      generate an error:

      Error: MediaPlayer - attempt to use a trait not on the media

       

      Thank you

        • 1. Re: Simple flex example
          Vincent Nabet Level 1

          I have now tested this code

           

          Nothing appears, no error, and handler are not triggerred... I do not really understand

           

          Thank you

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="_init();">
              <mx:Script>
                  <![CDATA[
                      import org.openvideoplayer.media.MediaPlayer;
                      import org.openvideoplayer.media.URLResource;
                      import org.openvideoplayer.net.NetLoader;
                      import org.openvideoplayer.net.NetStreamCodes;
                      import org.openvideoplayer.video.VideoElement;
                      import org.openvideoplayer.utils.URL;
                     
                      import org.openvideoplayer.events.MediaPlayerCapabilityChangeEvent;
                     
                     
                      private var player:MediaPlayer;
                     
                      private function _init():void
                      {
                          player = new MediaPlayer();
                         
                          player.addEventListener( MediaPlayerCapabilityChangeEvent.VIEWABLE_CHANGE, _onViewable );
                          player.autoRewind = false;
                          player.autoPlay = true;
                          player.source = new VideoElement( new NetLoader(), new URLResource( new URL ( "kennedy.flv" ) ) );
                      }
                     
                     
                      private function _onViewable(pEvent:MediaPlayerCapabilityChangeEvent):void
                      {
                          if(pEvent.enabled)
                          {
                              addChild(player.view);
                          }
                      }

           

                  ]]>
              </mx:Script>
                 
          </mx:Application>

          • 2. Re: Simple flex example
            charles_newman-6QjwQx Level 1

            Hi Vincent,

             

            Try changing your URL to this:

                 new URL ( "./kennedy.flv" ) 

             

            There is a bug filed for this.

             

            Thanks,

            - charles

            • 3. Re: Simple flex example
              Vincent Nabet Level 1

              It's ok !

              I have replaced too addChild(player.view); by   rawChildren.addChild(player.view); and all work fine.

               

              Thank you