Question

I've set up a little application that just shows a spark videoDisplay control loading a local file. The video plays ok as an AIR in windows and it plays ok in a browser over osx if the flex application is a web app, but whenever I try to run as a Flex AIR application on the Mac, the VideoDisplay goes through:

  • MediaPlayerState.LOADING
  • MEdiaPlayerState.READY
  • MediaPlayerState.PLAYBACK_ERROR

I can't find any clue on what is going on or the reason of that playback error. The video file is of course the same in all the cases.

I'm using Flex SDK 4.6 (comes with AIR 3.1) from Flash builder 4

Here it is the code I'm using for the test:

<?xml version="1.0" encoding="utf-8"?>    
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"     
  xmlns:s="library://ns.adobe.com/flex/spark"     
  xmlns:mx="library://ns.adobe.com/flex/mx">

<fx:Script>    
<![CDATA[    
import org.osmf.events.MediaPlayerStateChangeEvent;    

protected function mediaPlayerStateChangeHandler(event:MediaPlayerStateChangeEvent):void    
{    
    trace(event.state);    
}


]]>

</fx:Script>

    <s:VideoDisplay width="100%" height="100%" source="/somepath/video.mp4"     
                    mediaPlayerStateChange="mediaPlayerStateChangeHandler(event)"/>

</s:WindowedApplication>
Was it helpful?

Solution

The problem was the same as stated in this question: AIR: securityError on OSX (but not on Windows) with URLStream() For some reason AIR in OSX is not using the security sandbox and the source file path for the video must be provided as an URL.

So the code should be like:

<s:VideoDisplay width="100%" height="100%" source="{new File('/somepath/video.mp4').url}"     
                mediaPlayerStateChange="mediaPlayerStateChangeHandler(event)"/>

That way it works in osx and windows.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top