Akamai HLS live stream with AkamaiAdvancedStreamingPlugin
Akamai gave me a hard time making a live stream from their servers work in my flash video player. Originally I've been testing my streams in their stream testing app @ mediapm.edgesuite.net. Saw a &hdcore=3.3.0 parameter and some random string getting attached to the manifest.f4m request URL and after adding these parameters manually to mine the stream played fine in both Firefox and Chrome. That was never properly tested in Safari though and about a month later someone complained they couldn't see the stream.
For Safari, the akamai streaming server would block requests to the segment files with a 403 - Forbidden.
Talking to a dude at Akamai they provided me with libraries and a documentation file to integrate their AkamaiAdvancedStreamingPlugin in my project.
The docs were outdated and incomplete, the samples provided wouldn't compile because the maven repository server at mvn.akamai.com could at the time of writing this not be resolved.
Following the docs you're supposed to load their plugin swf from this URL:
which delivers a file but I reckon that plugin file must be for OSMF 1.6. or something because anytime I tried to load any stream it would throw an error and fail to play.
It took me forever groping around in the dark to find out that another plugin, the proper v3.3 file at
http://players.edgesuite.net/flash/plugins/osmf/advanced-streaming-plugin/v3.3/osmf2.0/AkamaiAdvancedStreamingPlugin.swf
Found this amongst the samples in a flex project and it worked without any trouble.
Finally, here's a working AS class that can play token-secured Akamai HDS streams utilising their plugin:
For Safari, the akamai streaming server would block requests to the segment files with a 403 - Forbidden.
Talking to a dude at Akamai they provided me with libraries and a documentation file to integrate their AkamaiAdvancedStreamingPlugin in my project.
The docs were outdated and incomplete, the samples provided wouldn't compile because the maven repository server at mvn.akamai.com could at the time of writing this not be resolved.
Following the docs you're supposed to load their plugin swf from this URL:
http://players.edgesuite.net/flash/plugins/osmf/advanced-streaming-
plugin/fp10.1/current/AkamaiAdvancedStreamingPlugin.swf
which delivers a file but I reckon that plugin file must be for OSMF 1.6. or something because anytime I tried to load any stream it would throw an error and fail to play.
It took me forever groping around in the dark to find out that another plugin, the proper v3.3 file at
http://players.edgesuite.net/flash/plugins/osmf/advanced-streaming-plugin/v3.3/osmf2.0/AkamaiAdvancedStreamingPlugin.swf
Found this amongst the samples in a flex project and it worked without any trouble.
Finally, here's a working AS class that can play token-secured Akamai HDS streams utilising their plugin:
package
{
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.system.Security;
import org.osmf.events.MediaFactoryEvent;
import org.osmf.media.DefaultMediaFactory;
import org.osmf.media.MediaElement;
import org.osmf.media.MediaPlayerSprite;
import org.osmf.media.URLResource;
import org.osmf.net.StreamType;
import org.osmf.net.StreamingURLResource;
[SWF(width='1280',height='720',backgroundColor='#000000',frameRate='60')]
public class HDCorePluginTester extends Sprite
{
private var mediaPlayerSprite:MediaPlayerSprite;
private var mediaFactory:DefaultMediaFactory;
public function HDCorePluginTester()
{
super();
Security.allowDomain("*");
Security.allowInsecureDomain("*");
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
mediaPlayerSprite = new MediaPlayerSprite();
mediaPlayerSprite.width = stage.stageWidth;
mediaPlayerSprite.height = stage.stageHeight;
addChild(mediaPlayerSprite);
mediaFactory = new DefaultMediaFactory;
loadPlugin("http://players.edgesuite.net/flash/plugins/osmf/advanced-streaming-plugin/v3.3/osmf2.0/AkamaiAdvancedStreamingPlugin-logging.swf");
}
protected function loadPlugin(source:String):void {
setupListeners();
mediaFactory.loadPlugin(new URLResource(source));
}
protected function onPluginLoad(event:MediaFactoryEvent):void {
setupListeners(false);
var rs:StreamingURLResource = new StreamingURLResource(
"http://multiformatlive-f.akamaihd.net/z/demostream_1@2131/manifest.f4m",
StreamType.LIVE
);
var mdma:MediaElement = mediaFactory.createMediaElement(rs);
mediaPlayerSprite.media = mdma;
}
protected function onPluginLoadError(event:MediaFactoryEvent):void
{
trace("plugin failed to load.");
setupListeners(false);
}
protected function setupListeners(add:Boolean=true):void
{
if (add) {
mediaFactory.addEventListener(
MediaFactoryEvent.PLUGIN_LOAD,
onPluginLoad);
mediaFactory.addEventListener(
MediaFactoryEvent.PLUGIN_LOAD_ERROR,
onPluginLoadError);
}
else
{
mediaFactory.removeEventListener(
MediaFactoryEvent.PLUGIN_LOAD,
onPluginLoad);
mediaFactory.removeEventListener(
MediaFactoryEvent.PLUGIN_LOAD_ERROR,
onPluginLoadError);
}
}
}
}
Kommentare
Kommentar veröffentlichen