Skip to main content
June 23, 2011
Question

Flv playback client side bandwidth detection? FMS 3

  • June 23, 2011
  • 1 reply
  • 1109 views

Has anyone been able to get bandwidth detection to work using the flvplayback control (client side - using AS3)? I have successfully got it to work using the video component with bwcheck and bwdone but I need to figure out how to do this with the FLV playback control. I am using FMS 3 and do not want to use the native bandwidth detection that comes with FMS. I need to detect the clients bandwidth and set the buffer time and what bitrate of a video (high, medium, low) I provide to a user based on their bandwidth.

In other words, is there an equivialant of bwcheck and bwdone that the flv playback can hook into to detect the client's bandwith?

I appreciate your help in advance!

Thank you,

Brad

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    June 24, 2011

    Can you check this article to see if this is helpful: http://www.adobe.com/devnet/flashmediaserver/articles/dynstream_advanced_pt1.html

    June 24, 2011

    Hi SE,

    Thanks for your link - I appreciate you providing it. It does not help me with what I am trying to do. I am going to provide this code snippet to provide an example of what I have got working using the video component with NetConnection and NetStream.

    Here are a few lines of this *code extracted below that I would like to point out. I am able to determine the clients bandwidth and write the bandwidth with p_event.bandwidth. I would really like to be able to do this using a FLV playback component - not the video component.

            // Event handler for Bandwidth event
             private function _onBandwidthReceived( p_event:BandwidthEvent ):void
             {
                 log( "Now we know our bandwidth!" );
                 log( "Bandwidth: " + p_event.bandwidth );
             }

    #START CODE SNIPPET#

    package com.bitratesample.document
    {
        import com.bitratesample.event.BandwidthEvent;
        import com.bitratesample.net.SimpleClient;
        import fl.controls.TextArea;
        import flash.display.MovieClip;
        import flash.net.NetConnection;
        import flash.events.NetStatusEvent;
        import flash.events.SecurityErrorEvent;
        import flash.events.IOErrorEvent;

        public class BandwidthTest extends MovieClip
        {
            public var output_txt:TextArea;
           
            public var rtmpPath:String = "####";
           
            private var _client:SimpleClient;
            private var _nc:NetConnection;
           
            public function BandwidthTest()
            {
                // Create the client
                _client = new SimpleClient();
               
                // Add the listener for the bandwidth result
                _client.addEventListener( BandwidthEvent.BANDWIDTH_RECEIVED, _onBandwidthReceived );
               
                // Create our net connection
                _nc = new NetConnection();
               
                // set the client on the NetConnection
                _nc.client = _client;
               
                // Create our listeners for the NetConnection
                _nc.addEventListener( NetStatusEvent.NET_STATUS, _onNetStatus );
               
                // Connect
                _nc.connect( rtmpPath, true );
            }
           
            private function log( p_msg:String ):void
            {
                trace( p_msg );
                output_txt.appendText( p_msg + "\n" );
            }
           
           // Event handler for Bandwidth event
            private function _onBandwidthReceived( p_event:BandwidthEvent ):void
            {
                log( "Now we know our bandwidth!" );
                log( "Bandwidth: " + p_event.bandwidth );
            }

           
            private function _onNetStatus( p_event:NetStatusEvent ):void
            {
                log( "p_event.info.code: " + p_event.info.code );
                switch( p_event.info.code )
                {
                    case "NetConnection.Connect.Success":
                    {
                        log( "The connection attempt succeeded." );
                        break;
                    }
                    case "NetConnection.Connect.Rejected":
                    {
                        log( "The connection attempt did not have permission to access the application." );
                        break;
                    }
                    case "NetConnection.Connect.Failed":
                    {
                        trace( "The connection attempt failed." );
                        break;
                    }
                }
            }
           
        }
       
    }

    #END CODE SNIPPET#

    If I can get this to work using the FLV playback component, I would like to write out statements like  %this% for example (bear with me, I am just writing examples below, I  realize the syntax is not correct)

    % START EXAMPLE STATEMENTS%

    if (p_event.bandwidth <= 2,000)  {
        player.bufferTime = 30;

       player.load(SmallBirateAndSmallDimensionVideo.flv);

      } else if (p_event.bandwidth > 2,000 || p_event.bandwidth <= 6,000) {

        player.bufferTime = 15;

       player.load(MediumBirateAndMediumDimensionVideo.flv);
       }

      } else {

      player.bufferTime = 2;

      player.load(HighBirateAndHighDimensionVideo.flv);

    }

    % END EXAMPLE STATEMENTS%

    Is there any way I can detect the clients bandwidth using client side action script 3 code.

    I am using FMS 3.0.

    I do not want to use the native bandwidth detection that comes with FMS 3.0


    Thank you,

    Brad