13 Replies Latest reply on May 26, 2010 7:04 AM by FTQuest

    AudioElement causes an error in Flex 4

    FTQuest Level 3

      Greetings,

       

      A few days ago Ryan and Brian helped me to patch the problem wtih importing video into Flex by using the 'loadForCompatibility' flag.

      This morning I ran into similar problem with audio: the SWF that uses simplest OSMF player plays fine in the Flash CS5 and in the standalone FlashPlayer. Once I import the SWF into Flex 4, even with the SWFLoader flag 'loadForCompatibility' set to 'true', I get this error: Screen shot 2010-05-08 at 10.37.21 AM.png

      Here is the code for the simplest audio player class (by the way, for some unclear reasons getter/setter didn't work, so for the test case I had to set the variable as 'public' ):

       

      package

      {

      import flash.display.Sprite;

       

      import org.osmf.media.MediaPlayer;

      import org.osmf.media.URLResource;

      import org.osmf.elements.AudioElement;

       

      public class LightAudioElement extends Sprite

      {

      public var audioPlayer:MediaPlayer;

       

       

      public function LightAudioElement(aSource:String)

      {

      var resource:URLResource = new URLResource(aSource);

      var audioElement:AudioElement = new AudioElement(resource);

       

      audioPlayer = new MediaPlayer();

      audioPlayer.media = audioElement;

      audioPlayer.autoRewind = true;

      }

      }

      }

       

      And here is the code for the SWF:

       

      import LightAudioElement;

      import flash.events.MouseEvent;

       

      var snd:LightAudioElement = new LightAudioElement('assets/Test.mp3');

      snd.audioPlayer.autoPlay = false;

       

      //Standard Button component dragged on the stage for this quick test

      sndBtn.addEventListener(MouseEvent.CLICK, clickHandler);

       

      function clickHandler(event:MouseEvent):void

      {

      if(snd.audioPlayer.playing)

      snd.audioPlayer.stop();

      else

      snd.audioPlayer.play();

      }

       

      Once again, it works fine in both Flash CS5 and standalone FlashPlayer, but produces an error in Flex 4. I'm on OS X 10.6.3, the Flex SDK 4.0

       

      Thanks in advance for any suggestions,

      FTQuest

        • 1. Re: AudioElement causes an error in Flex 4
          FTQuest Level 3

          In case somebody runs into that problem as well, it seems - at least at the moment - that compiling the swf within the FlashBuilder bypasses the problem.

          FTQuest

          • 2. Re: AudioElement causes an error in Flex 4
            FTQuest Level 3

            One more question:

            What are possible 'cons' of replacing the OSMF.swc in the the Flex SDK with the latest 0.95 version?

            I have tried that, and so far it even allows me to import in Flex the SWFs compiled in Flash CS 5 where I have two simple Audio and Video OSMF players.

            Still there are a few things that work in Flash and standalone Player, but do not work in Flex. For example, I can listen to 'TimeEvent.CURRENT_TIME_CHANGE' in Flash and standalone, but it does NOT work in Flex.

             

            FTQuest

            • 3. Re: AudioElement causes an error in Flex 4
              FTQuest Level 3

              One more question:

              Can't find ANY reference on: 1046: TypeWas not found or was not a compile-time constant: DimensionEvent

              Seems that it's caused by applying any skin to the player, including the VideoPlayer shipped with Flex.

              FT

              • 4. Re: AudioElement causes an error in Flex 4
                bringrags Level 4

                I'd advise against replacing Flex's OSMF.swc with the latest one.  The reason is that the Flex SDK integrates with OSMF APIs from a much earlier sprint, and in the latest OSMF SWC many of these APIs don't exist anymore (due to renaming).  I'd be surprised if cross-version integration worked at all.  (And this is likely the reason for the DimensionEvent error -- this was a class we had in an earlier version of OSMF, which has since been supplanted by DisplayObjectEvent.)  In a subsequent release of Flex, the Flex team will be integrating their component with a more recent version of OSMF.

                1 person found this helpful
                • 5. Re: AudioElement causes an error in Flex 4
                  FTQuest Level 3

                  Hi Brian,

                   

                  Thanks for the advice. Could you tell me, which version of the OSMF is used in the Flex 4 release, so that I'd use that version in the Flash CS 5?

                   

                  Thanks,

                  FTQuest

                  • 6. Re: AudioElement causes an error in Flex 4
                    bringrags Level 4

                    I believe the version number is 0.7.  There's also a branch in the public SVN repository called "flex4", you can see it here:

                     

                    http://opensource.adobe.com/svn/opensource/osmf/branches/flex4/

                    • 7. Re: AudioElement causes an error in Flex 4
                      FTQuest Level 3

                      Thanks Brian.

                      I'll give it a try.

                      FTQuest

                      • 8. Re: AudioElement causes an error in Flex 4
                        FTQuest Level 3

                        Sorry to bug you, Brian, but it still doesn't work.

                         

                        Following the instructions in the ReadMe I tried to run in the release Flex 4 the 'ExamplePlayer' from the 0.7 version of the Sprint

                        Once I import the project folder I get instantly the error in the Problems window: 'unable to open'/MediaFramework/bin/MediaFramwork.swc'

                        Adding manually this swc from the source_07 didn't help.

                        Then I tried to compile despite that error, using the 'Proceed with launch?', but got another error: File not found:/file:/Users/../ExamplePlayer/bin-debug/ExmplePlayer.html

                         

                        Any suggestions?

                        FTQuest

                        • 9. Re: AudioElement causes an error in Flex 4
                          bringrags Level 4

                          Are you working solely with the code from the "flex4" branch I linked in my previous post?  Or a mixture?  If the former, then you may need to adjust the build order to ensure that MediaFramework is compiled before ExamplePlayer.  (The default build order in Flex Builder doesn't work for all OSMF projects, and there apparently isn't a way for us to specify that.)  Also, note that the "OSMF" project was previously named "MediaFramework", so make sure you have the older version imported.

                          • 10. Re: AudioElement causes an error in Flex 4
                            FTQuest Level 3

                            Yes, I use the code from the branch you gave me.

                            Also, I unchecked the automatic build, so that I'm able to verify that in the LibraryPath the MediaFramework is listed prior to building the project. And still, after all this has been verified, once I choose build - the same two errors pop-up.

                            • 11. Re: AudioElement causes an error in Flex 4
                              st-f Level 1

                              sorry for the double comment^^ - dont get how to delete it

                              • 12. Re: AudioElement causes an error in Flex 4
                                st-f Level 1

                                Same kind of problems here... Using an audioElement inside a parallelElement, CURRENT_TIME_CHANGE is working, but it's not dispatched anymore after seeking (it's working when seeking a videoElement inside a parallelElement), and SEEK_CHANGE is never dispatched.

                                • 13. Re: AudioElement causes an error in Flex 4
                                  FTQuest Level 3

                                  Hi,

                                   

                                  First, and foremost. As Brian Riggs - who is ultimate authority on the subject - has said:

                                  I'd advise against replacing Flex's OSMF.swc with the latest one.  The reason is that the Flex SDK integrates with OSMF APIs from a much earlier sprint, and in the latest OSMF SWC many of these APIs don't exist anymore (due to renaming).

                                   

                                  And that's what I take seriously.

                                   

                                  Yet, out of curiosity, and for the sake of exploration I took my chances and did replace the version of the OSMF that is shipped with the Flex 4.0 release with the latest - 0.95.

                                   

                                  So far, all the functionality that I need - single player, multiple players, compiled in Flash, compiled in Flex, playing in synch, or alternating - seems working fine, including access to various events.

                                   

                                  Let me repeat: this is NOT a suggestion; just mere sharing of experience, and it comes at a cost - you should use your versions of video player, i.e. built in that latest version of OSMF. The Spark VideoPlayer (or VideoDisplay) give you compile time error I mentioned before - TimeDimension.

                                   

                                  Just FYI,

                                  FTQuest