Skip to main content
Participating Frequently
October 15, 2010
Question

player hangs on macintosh

  • October 15, 2010
  • 1 reply
  • 289 views

Hello,

I have been experiencing a somewhat random inability of my player to  load on a Macintosh.  It doesn't happen everytime, maybe 2 out of 10  times.  This does not happen on a Pc.

My flash file is  actionscript 2.0, and I have enabled hardware acceleration.  This issue  was happening before I enabled the hardware acceleration.

Here is the player I am talking about:
http://somapps.med.upenn.edu/oe/oe/video/player.html

We currenlty don't have the password for the administration console, so I haven't been able to monitor it that way.

Thanks

    This topic has been closed for replies.

    1 reply

    Participating Frequently
    October 15, 2010

    Here is my actionscript:

    /*
    VARIABLES TO CHANGE!  

    to find  applicable comments throughout this code, search for ''

    connStr =     connection string. FMS server to connect to.
    app =         application on FMS server you want to connect to
    lowStream = lower of 2 bitrates. Should be 150kbps
    highStream = higher of 2 bitrates. Should be 500kbps
    */
    var connStr:String = "rtmp://165.123.243.191"
    //var connStr:String = "rtmp://170.212.245.116"
    //var connStr:String = "rtmp://170.166.234.51";
    var app:String = "vod";
    var lowStream:String = "SOMv/fac_affairs/75_kbsp";
    var highStream:String = "SOMv/fac_affairs/75_kbsp";

    /*
    to trouble shoot from the client side, comment out the line below by
    replacing the line below with the following:
    //logTxt._visible = true;
    */
    logTxt._visible = true;


    var nc:NetConnection;
    var ns:NetStream;

    var kbps:Number = 0;
    var hiccupCnt:Number = 0;

    var stream:String;
    var timerID:Number;

    var soundObj:Sound;
    var volumeIncrement:Number ;

    var ncReady:Boolean;
    var streamLen:Number;
    var currentVolume:Number;

    // set up
    initialize();

    function initialize() {
       
        // initialize variables
        volumeIncrement = 20;
        ncReady = false;
        streamLen = -1;
        currentVolume = 60;
        stream = "";
        nc = new NetConnection();
       
        // initialize screen objects
        hung._visible = false;
        gui.playPauseBtn._visible = false;
        gui.fullScreenBtn._visible = false;
        gui.playPauseBtn.pauseBtn._visible = true;
        gui.playPauseBtn.playBtn._visible = false;
        gui.volumeSlider.volumeScrubber._y = 10;   
        gui.articulate_finish._visible = false;
        go();
       
    }

    function go() {       
        nc.connect( connStr + "/" + app );
    }

    // user wants to turn up volume
    gui.volumeUpBtn.onPress = function() {
        if ( currentVolume < 100 ) {
            currentVolume += volumeIncrement;
        }
       
        soundObj.setVolume( currentVolume );
        gui.volumeTxt.text = currentVolume + "%";
    }

    // user wants to turn down volume
    gui.volumeDownBtn.onPress = function() {
        if ( currentVolume > 0 ) {
            currentVolume -= volumeIncrement;
        }
       
        soundObj.setVolume( currentVolume );
       
        if ( currentVolume == 0 ) {
            gui.volumeTxt.text = "Muted";
        } else {
            gui.volumeTxt.text = currentVolume + "%";   
        }
    }

    // play sheet is visible the first time the user loads the app
    playBtnSheet.onPress = function ( evt ) {
        if ( kbps > 0 ) {
            logTxt._visible = true;
            playBtnSheet._visible = false;
            playStream()   
        }
    }

    // user hit the play/pause toggle button
    gui.playPauseBtn.onPress = function( evt ) {
        if ( gui.playPauseBtn.playBtn._visible ) {
            gui.playPauseBtn.playBtn._visible = false;
            gui.playPauseBtn.pauseBtn._visible = true;   
            //timerID = setInterval( onTimer, 50 );
        } else {
            gui.playPauseBtn.playBtn._visible = true;
            gui.playPauseBtn.pauseBtn._visible = false;
            //clearInterval( timerID );
        }

        ns.pause();
    }

    // on netconnection status
    nc.onStatus = function ( evt:Object) {

        writeLog( evt.code );

        if (evt.code == "NetConnection.Connect.Success") {
           
            ns = new NetStream( nc );
            vid.attachVideo( ns );
            nc.call( "checkBandwidth" );
            initStream();
           
        } else {
            writeLog( "Error connecting to FMS: " + evt.code );
            writeLog( "FMS: " + connStr );
            writeLog( "app: " + app );
            hung._visible = true;
        }
    }

    nc.onBWCheck = function() {}
    nc.onBWDone = function( _Kbps, w, e, r ) {
       
        var first = false;
        if ( !kbps || kbps == 0 ) {
            first = true;
        }
       
        kbps = _Kbps*8;
        pos = ns.time;
       
        if ( !first ) {       
            playStream();
        }
       
        if ( kbps > 0 )
            waitScreen._visible = false;
       
        writeLog("current bw is "+kbps );
    }

    function getStream() {

        if ( kbps < 540 ) {
            stream = lowStream;
        } else {
            stream = highStream;
        }
    }

    function playStream() {
        getStream();
        ns.play( stream, pos );   
    }

    // initialize our stream
    function initStream():Void {
       
        /*
        UPENN
        this line shows a thumb nail of the video 4 seconds in. To specify
        another frame in the video to show as a thumbnail, change the 4 below
        */   
        ns.play( highStream, 4, 0 );  

        // netstream NetStatus event handler
        ns.onStatus = function( evt:Object ) {

            writeLog( evt.code );
           
            // our buffer is full, so we can add more space for buffering (assuming we have exess BW)
            if ( evt.code == "NetStream.Buffer.Full" ) {
                writeLog( "Buffer full, increasing buffer size by 3 seconds" );
                ns.setBufferTime( ns.bufferTime + 3 );
           
                hiccupCnt--;
               
                if ( hiccupCnt < -3 && stream != highStream ) {
                    hiccupCnt = 0;
                    nc.call( "checkBandwidth" );               
                }
               
            } else if ( evt.code == "NetStream.Buffer.Empty" ) {
                writeLog( "Buffer empty, decreasing buffer size to .1 seconds" );
                ns.setBufferTime( 0.1 );
               
                hiccupCnt++;
               
                if ( hiccupCnt > 3 && stream != lowStream ) {
                    hiccupCnt = 0;
                    nc.call( "checkBandwidth" );
                }
            }
        }
               
        ns.onMetaData = function( info ) {
           
            streamLen = info.duration;
           
            // adjust video player width and height to fit the video
            vid._height = info.height;
            vid._width = info.width;
           
            vid._x = (720 - vid._width) / 2;
            vid._y = (540 - vid._height) / 2;
           
            gui.totalTimeTxt.text = "/ " + hhmmss( streamLen );
        }      

        timerID = setInterval( onTimer, 50 );

        gui.playPauseBtn._visible = true;
        gui.fullScreenBtn._visible = true;   
       
        // attach sound control to our stream
        createEmptyMovieClip("soundMc", this.getNextHighestDepth());
        soundMc.attachAudio(ns);
        soundObj = new Sound(soundMc);
        soundObj.setVolume( currentVolume );
        gui.volumeTxt.text = Number( currentVolume ) + "%";
       
        ncReady = true;
    }

    // fast forward a minute
    gui.fastForwardBtn.onPress = function() {
        if ( ns.time + 60 < streamLen ) {
            ns.seek( ns.time + 60 );
        } else {
            ns.seek( streamLen );
        }
    }

    // jump back a minute
    gui.fastBackwardBtn.onPress = function() {
        if ( ns.time - 60 > 0 ) {
            ns.seek( ns.time - 60 );
        } else {
            ns.seek( 0 );
        }
    }

    // seek ahead 10 seconds
    gui.forwardBtn.onPress = function() {
        if ( ns.time + 10 < streamLen ) {
            ns.seek( ns.time + 10 );
        } else {
            ns.seek( streamLen );
        }
    }

    // seek back 10 seconds
    gui.backwardBtn.onPress = function() {
        if ( ns.time - 10 > 0 ) {
            ns.seek( ns.time - 10 );
        } else {
            ns.seek( 0 );
        }
    }

    // triggered 20 times a second to update the progress text
    function onTimer() {   
        gui.progressTxt.text = hhmmss( ns.time );
       
        var endMovie = Math.round( streamLen - ns.time );

        if ( endMovie == 0 ){
            gui.articulate_finish._visible = true;
        } else {
            gui.articulate_finish._visible = false;
        }
    }

    function writeLog( msg ) {
        logTxt.text += msg + "\n";
       
        // make sure the log doesn't get too long
        if ( logTxt.text.length > 3000 ) {
            logTxt.text = logTxt.text.substring( logTxt.text.length - 3000 );
        }
       
        // auto scroll the log text area
        logTxt.verticalScrollPosition = logTxt.maxVerticalScrollPosition;
    }

    // converts seconds into hh:mm:ss format
    function hhmmss( secs : Number ) : String {
        var ss,mm,hh, sTime : String;
        var mins, hrs : Number;
        hrs = 0;
        mins = 0;
        ss = 0;
       
        if (secs >= 60) {
            mins = Math.floor( secs/60);
            secs = secs - (mins*60);
        }
        if (mins >= 60) {
            hrs = Math.floor( mins/60);
            mins = mins - (hrs*60);
        }
       
        ss = '0'+ Math.floor( secs );
        ss = ss.substr( ss.length-2 ,2);
        mm = '0'+mins;
        mm = mm.substr( mm.length-2 ,2);
        hh = String(hrs);
       
        sTime = '';
        if (hh != '0') sTime += hh + ":";
        sTime += mm + ":";
        sTime += ss;
       
               
        return sTime;
    }