Copy link to clipboard
Copied
package {
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.NetStatusEvent;
import flash.events.StageVideoAvailabilityEvent;
import flash.geom.Rectangle;
import flash.media.StageVideo;
import flash.media.StageVideoAvailability;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.display.MovieClip;
public class Main extends MovieClip {
private const STREAM_URL:String = "https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8";
private var netConnection:NetConnection;
private var netStream:NetStream;
private var video:StageVideo;
private var addedToStage:Boolean;
private var svEnabled:Boolean;
public function Main() {
super();
addEventListener(Event.ADDED_TO_STAGE,onAddedToStage);
}
private function onAddedToStage(e:Event) :void{
stage.addEventListener(StageVideoAvailabilityEvent.STAGE_VIDEO_AVAILABILITY, onAvail);
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
protected function onAvail(event:StageVideoAvailabilityEvent):void{
if(event.availability == StageVideoAvailability.AVAILABLE){
svEnabled = true;
}
connectStream();
}
private function connectStream():void {
if (!svEnabled)
return;
netConnection = new NetConnection();
netConnection.addEventListener(NetStatusEvent.NET_STATUS, onConnectionNetStatus);
netConnection.connect(null);
}
private function onConnectionNetStatus(event:NetStatusEvent):void {
if (event.info.code == "NetConnection.Connect.Success")
startStream();
}
private function startStream():void {
netStream = new NetStream(netConnection);
netStream.client = this;
video = stage.stageVideos[0];
video.viewPort = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);
video.attachNetStream(netStream);
netStream.play(STREAM_URL);
}
private function onMetaData():void {}
}
}
Copy link to clipboard
Copied
import org.mangui.hls.HLS;
import org.mangui.hls.event.HLSEvent;
import flash.display.Sprite;
import flash.media.Video;
private var hls : HLS = null;
private var video : Video = null;
protected var _mediaPosition : Number;
protected var _duration : Number;
public function Player(): void {
hls = new HLS();
hls.stage = this.stage;
video = new Video();
video.height=100;
video.width=100;
videoContainer.addChildAt(video,0);
video.smoothing = true;
video.attachNetStream(hls.stream);
hls.load("http://xxxxxxxxxxxx.m3u8");
}
Copy link to clipboard
Copied
there is can not upload the flashls.swc please send me your email.I will send flashls.swc to your email
Copy link to clipboard
Copied
you can download the flashls.swc from https://github.com/mangui/flashls/tree/dev/bin/release
Copy link to clipboard
Copied
Thanks for replying. I'll check it out soon. I actually did manage to run it with this code:
var ncMain:NetConnection;
var nsMain:NetStream;
var svMain:StageVideo;
ncMain = new NetConnection();
ncMain.connect(null);
nsMain = new NetStream(ncMain);
nsMain.client = this;
svMain = stage.stageVideos[0];
svMain.attachNetStream(nsMain);
svMain.viewPort = new Rectangle(0,0,1024,768);
nsMain.play("https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8");
I have some questions. If I use an mp4 file and place it on the ios devices storage it gets played but if I move it to a server then it won't be played on ios. Does it mean I can only play videos with m3u8 (HLS) on ios? I know that apple demands HLS for celular usage. Can adobe AIR play RTMP streams on both Android and iOS?