Skip to main content
Inspiring
Mar 25, 2019 9:23 PM UTC
Question

I can't get the .m3u8 (HLS) to play

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 {}

    }

       

}

This topic is closed to new replies. Start a new post to keep the conversation going.

4 replies

mingtianjian
Inspiring
Mar 26, 2019 5:40 AM UTC

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");

}

Translate
mingtianjian
Inspiring
Mar 26, 2019 5:42 AM UTC

there is can not upload the  flashls.swc  please send me your email.I will send flashls.swc to your email

Translate
mingtianjian
Inspiring
Mar 26, 2019 5:45 AM UTC

you can download the flashls.swc from https://github.com/mangui/flashls/tree/dev/bin/release

Translate