我正试图将一个简单的OSMF播放器插入到我的fex应用程序中。但它不起作用。这是我的代码:
<?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"/>
我在运行应用程序时遇到白屏
谢谢
答案 0 :(得分:2)
这是纯粹的AS,如何做到这一点:
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);
}
}
}
对于flex,将playerSprite添加到你的UIComponent容器而不是最后一行的sprite。