androidactionscript-3airamazon-cloudfrontnetstream

netstream no working on adobe air - amazon s3 - signed cloudfront


I can't seem to get net stream to work on my adobe air application. Android or desktop.

Here is the code with the valid link. The link works on VLC.

Any suggestions?

   public function Main() {
        url = "rtmp://s1p2w2yhnipjkt.cloudfront.net/cfx/st/mp4:demo.mp4?Expires=1594281188&Signature=AW0M39xRqX5bjhlw4EPMvdPzum8~gbK6Wsl7vkI3av6cWDXQ36lCfTlnpOXse6qiP9RSbuT-jhor84DHvZg7yPmvnnlPgAEQlndtgsBvzwUj~kGXES~~VWvHGVuUHTDnK~rAWcOmzpbRi-jWPpN71Ks2wnJeri596lqh2dOkUcg_&Key-Pair-Id=APKAI7XWAS4L22TVE3HA";
    _netConnection = new NetConnection();
    _netConnection.addEventListener(NetStatusEvent.NET_STATUS, onConnect);
    _netConnection.client = {onBWDone:onNetConnectionBWDone};


    _netConnection.connect(url);
    _netConnection.connect("rtmp://s1p2w2yhnipjkt.cloudfront.net/cfx/st");

    trace("connect")


}

private function onConnect(event:NetStatusEvent):void {

    trace(event.info.code);
    if(event.info.code == "NetConnection.Connect.Success")
    {
        _netStream = new NetStream(_netConnection);
        _netStream.client = {onMetaData:onMetaData, onPlayStatus :onPlayStatus};
        var video:Video = new Video();
        video.attachNetStream(_netStream)
        _netStream.play("mp4:demo.mp4");
        addChild(video);

    }

}

Solution

  • I tested your stream in my android device and it's working fine, and I think that your forgot to use the params with your stream, so you can do like this :

    var url:String = 'rtmp://s1p2w2yhnipjkt.cloudfront.net/cfx/st',
                // or rtmp://s1p2w2yhnipjkt.cloudfront.net:80/cfx/st
        stream:String = 'mp4:demo.mp4?Expires=1594281188&Signature=AW0M39xRqX5bjhlw4EPMvdPzum8~gbK6Wsl7vkI3av6cWDXQ36lCfTlnpOXse6qiP9RSbuT-jhor84DHvZg7yPmvnnlPgAEQlndtgsBvzwUj~kGXES~~VWvHGVuUHTDnK~rAWcOmzpbRi-jWPpN71Ks2wnJeri596lqh2dOkUcg_&Key-Pair-Id=APKAI7XWAS4L22TVE3HA';
    
    // ...
    
    _netConnection.connect(url);
    
    // ...
    
    _netStream.play(stream);
    

    Of course you have to add the INTERNET permission to your app to be able to get the stream, and also to be sure that your device can connect to the video server via the port 1935 or 80 (at worst).

    Hope that can help.