Skip to main content
Participant
October 23, 2011
Question

RTMP works on Android, but doesn't work on iOS!

  • October 23, 2011
  • 2 replies
  • 1518 views

Hi guys,

I'm really stuck, don't know why recently my app can't play some rtmp streamers, it can only work with some others. Previously there was no issue.

Could you see the below peice of code. This one works fine on PC and Android, but not on iOS.

import flash.events.*;

import flash.media.Video;

import flash.net.*;

var client:MediaClient = new MediaClient();

var connection:NetConnection = new NetConnection();

connection.client = client;

// connection.proxyType = "best";

connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

connection.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);

connection.connect("rtmp://66.160.142.198/live");

var stream:NetStream;

var video:Video = new Video(480, 320);

addChild(video);

function netStatusHandler(evt:NetStatusEvent):void

{

   switch(evt.info.code)

   {

       case "NetConnection.Connect.Success":

           stream = new NetStream(connection);

           stream.client = client;

           stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);

           stream.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);

           stream.play("vtv11");

           video.attachNetStream(stream);

           break;

       default:

           // output evt.info.code on screen

           break;

   }

}

function securityErrorHandler(evt:SecurityErrorEvent):void

{

   // output evt.toString() on screen

}

function asyncErrorHandler(evt:AsyncErrorEvent):void

{

   // output evt.toString() on screen

}

-------------------------------------------------------

and here is MediaClient class:

-------------------------------------------------------

package

{

   public class MediaClient

   {

       public function onBWDone(...args):void

       {

           // ouput args

       }

       public function onFI(...args):void

       {

           // ouput args

       }

       public function onMetaData(...args):void

       {

           // ouput args

       }

       public function close(...args):void

       {

           // ouput args

       }

   }

}

----------------------------------

I tried to output some debug text, I saw it netconnecton was connected, the server invoked onFI() every about 2 seconds, but there's no video and sound. (tested on iOS 4, both 3G and wifi).

I also tried alot of options of the video, netstream and netconnection classes and tried with OSMF, but can't get it work. (I'm using AIR 3.0 sdk).

Thank you so much!

This topic has been closed for replies.

2 replies

Inspiring
November 3, 2011

Can you post what type of stream you're trying to view? 

There are compatibility issues with H.264 and iOS over RTMP/RTMFP.  If your video stream is H.264, then you won't be able to view it on iOS over RTMP.  In that case, though, you *should* still be able to hear the audio (depending on what audio codec you're using).

Participant
October 31, 2011

Is there any solution please?