0

我设置了一个小应用程序,它只显示一个加载本地文件的 spark videoDisplay 控件。如果 flex 应用程序是 web 应用程序,视频在 windows 中可以作为 AIR 播放,并且在 osx 上的浏览​​器中可以正常播放,但是每当我尝试在 Mac 上作为 Flex AIR 应用程序运行时,VideoDisplay 都会出现:

  • MediaPlayerState.LOADING
  • 媒体播放器状态.READY
  • MediaPlayerState.PLAYBACK_ERROR

我找不到任何关于发生了什么或播放错误的原因的线索。视频文件当然在所有情况下都是相同的。

我正在使用 Flash builder 4 中的 Flex SDK 4.6(AIR 3.1 随附)

这是我用于测试的代码:

<?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>
4

1 回答 1

0

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.

于 2014-01-21T23:26:06.593 回答