dojox/av/_Media.js

  • Provides:

    • dojox.av._Media
  • dojox.av._Media

    • type
      Function
    • summary
      Used as a mixin for dojox and AIR media
    • description
      Calculates the current status of the playing media and fires
      the appropriate events.
  • dojox.av._Media.mediaUrl

    • summary
  • dojox.av._Media.initialVolume

    • type
      Float
    • summary
      The initial volume setting of the player. Acccepts between 0 and 1.
  • dojox.av._Media.autoPlay

    • type
      Boolean
    • summary
      Whether the video automatically plays on load or not.
  • dojox.av._Media.bufferTime

    • type
      Number
    • summary
      Time in milliseconds that the video should be loaded before it will
      play. May pause and resume to build up buffer. Prevents stuttering.
      Note:
      Older FLVs, without a duration, cannot be buffered.
  • dojox.av._Media.minBufferTime

    • type
      Number
    • summary
      Time in milliseconds bwteen the playhead time and loaded time that
      will trigger the buffer. When buffer is triggered, video will pause
      until the bufferTime amount is buffered.
      Note: Should be a small number, greater than zero.
  • dojox.av._Media.updateTime

    • type
      Number
    • summary
      How often, in milliseconds to get an update of the video position.
  • dojox.av._Media.id

    • type
      String
    • summary
      The id of this widget and the id of the SWF movie.
  • dojox.av._Media.isDebug

    • type
      Boolean
    • summary
      Setting to true tells the SWF to output log messages to Firebug.
  • dojox.av._Media.percentDownloaded

    • type
      read-only-Number
    • summary
      The percentage the media has downloaded; from 0-100
  • dojox.av._Media._flashObject

    • type
      read-only-Object
    • summary
      The dojox.embed object
  • dojox.av._Media.flashMedia

    • type
      read-only-SWF
    • summary
      The SWF object. Methods are passed to this.
  • dojox.av._Media.allowScriptAccess

    • type
      String
    • summary
      Whether the SWF can access the container JS
  • dojox.av._Media.allowNetworking

    • type
      String
    • summary
      Whether SWF is restricted to a domain
  • dojox.av._Media.wmode

    • type
      String
    • summary
      The render type of the SWF
  • dojox.av._Media.allowFullScreen

    • type
      Boolean
    • summary
      Whether to allow the SWF to go to fullscreen
  • dojox.av._Media._initStatus

    • type
      Function
    • source: [view]
        this.status = "ready";
        this._positionHandle = dojo.connect(this, "onPosition", this, "_figureStatus");
    • summary
      Connect mediaStatus to the media.
  • dojox.av._Media.getTime

    • type
      Function
    • source: [view]
        return this.flashMedia.getTime(); // Float
    • summary
      Returns the current time of the video
      Note:
      Consider the onPosition event, which returns
      the time at a set interval. Too many trips to
      the SWF could impact performance.
    • returns
      Float
  • dojox.av._Media.onLoad

    • type
      Function
    • parameters:
      • mov: (typeof SWF)
    • source: [view]
        // summary:
        //   Fired when the SWF player has loaded
        //   NOT when the video has loaded
        //
    • summary
      Fired when the SWF player has loaded
      NOT when the video has loaded
  • dojox.av._Media.onDownloaded

    • type
      Function
    • parameters:
      • percent: (typeof Number)
    • source: [view]
        // summary:
        //  Fires the amount of that the media has been
        //  downloaded. Number, 0-100
    • summary
      Fires the amount of that the media has been
      downloaded. Number, 0-100
  • dojox.av._Media.onClick

    • type
      Function
    • parameters:
      • evt: (typeof Object)
    • source: [view]
        // summary:
        //   TODO: Return x/y of click
        //   Fires when the player is clicked
        //   Could be used to toggle play/pause, or
        //   do an external activity, like opening a new
        //  window.
    • summary
      TODO: Return x/y of click
      Fires when the player is clicked
      Could be used to toggle play/pause, or
      do an external activity, like opening a new
      window.
  • dojox.av._Media.onSwfSized

    • type
      Function
    • parameters:
      • data: (typeof Object)
    • source: [view]
        // summary:
        //   Fired on SWF resize, or when its
        //   toggled between fullscreen.
    • summary
      Fired on SWF resize, or when its
      toggled between fullscreen.
  • dojox.av._Media.onMetaData

    • type
      Function
    • parameters:
      • data: (typeof Object)
      • evt: (typeof Object)
    • source: [view]
        this.duration = data.duration;
    • summary
      The video properties. Width, height, duration, etc.
      NOTE: 	if data is empty, this is an older FLV with no meta data.
      Duration cannot be determined. In original FLVs, duration
      could only be obtained with Flash Media Server.
      NOTE: 	Older FLVs can still return width and height
      and will do so on a second event call
  • dojox.av._Media.onPosition

    • type
      Function
    • parameters:
      • time: (typeof Float)
    • source: [view]
        // summary:
        //  The position of the playhead in seconds
    • summary
      The position of the playhead in seconds
  • dojox.av._Media.onStart

    • type
      Function
    • parameters:
      • data: (typeof Object)
    • source: [view]
        // summary:
        //   Fires when video starts
        //   Good for setting the play button to pause
        //   during an autoPlay for example
    • summary
      Fires when video starts
      Good for setting the play button to pause
      during an autoPlay for example
  • dojox.av._Media.onPlay

    • type
      Function
    • parameters:
      • data: (typeof Object)
    • source: [view]
        // summary:
        //   Fires when video starts and resumes
    • summary
      Fires when video starts and resumes
  • dojox.av._Media.onPause

    • type
      Function
    • parameters:
      • data: (typeof Object)
    • source: [view]
        // summary:
        //   Fires when the pause button is clicked
    • summary
      Fires when the pause button is clicked
  • dojox.av._Media.onEnd

    • type
      Function
    • parameters:
      • data: (typeof Object)
    • source: [view]
        // summary:
        //   Fires when video ends
        //   Could be used to change pause button to play
        //   or show a post video graphic, like YouTube
    • summary
      Fires when video ends
      Could be used to change pause button to play
      or show a post video graphic, like YouTube
  • dojox.av._Media.onStop

    • type
      Function
    • source: [view]
        // summary:
        // Fire when the Stop button is clicked
        // TODO:  This is not hooked up yet and shouldn't
        //   fire.
    • summary
      Fire when the Stop button is clicked
      TODO: 	This is not hooked up yet and shouldn't
      fire.
  • dojox.av._Media.onBuffer

    • type
      Function
    • parameters:
      • isBuffering: (typeof Boolean)
    • source: [view]
        this.isBuffering = isBuffering;
    • summary
      Fires a boolean to tell if media
      is paused for buffering or if buffering
      has finished
  • dojox.av._Media.onError

    • type
      Function
    • parameters:
      • data: (typeof Object)
      • url: (typeof String)
    • source: [view]
        console.warn("ERROR-"+data.type.toUpperCase()+":", data.info.code, " - URL:", url);
    • summary
      Fired when the player encounters an error
    • example
      
       console.warn("ERROR-"+data.type.toUpperCase()+":",
      		data.info.code, " - URL:", url);
  • dojox.av._Media.onStatus

    • type
      Function
    • parameters:
      • data: (typeof Object)
    • source: [view]
        // summary:
        //   Simple status
    • summary
      Simple status
  • dojox.av._Media.onPlayerStatus

    • type
      Function
    • parameters:
      • data: (typeof Object)
    • source: [view]
        // summary:
        //   The status of the video from the SWF
        //   playing, stopped, bufering, etc.
    • summary
      The status of the video from the SWF
      playing, stopped, bufering, etc.
  • dojox.av._Media.onResize

    • type
      Function
    • source: [view]
    • summary
  • dojox.av._Media._figureStatus

    • type
      Function
    • source: [view]
        var pos = this.getTime();
        //console.log(pos, this.duration, (pos>this.duration-.5), (this.duration && pos>this.duration-.5))


        if(this.status=="stopping"){
         // stop was fired, need to fake pos==0
         this.status = "stopped";
         this.onStop(this._eventFactory());


        }else if(this.status=="ending" && pos==this._prevPos){
         this.status = "ended";
         this.onEnd(this._eventFactory());


        }else if(this.duration && pos>this.duration-.5){
         this.status="ending"


        }else if(pos===0 ){//|| this.status == "stopped"
         if(this.status == "ready"){
          //never played
         }else{
          //stopped
          this.status = "stopped";
          if(this._prevStatus != "stopped"){
           this.onStop(this._eventFactory());
          }
         }


        }else{
         // pos > 0
         if(this.status == "ready"){
          //started
          this.status = "started";
          this.onStart(this._eventFactory());
          this.onPlay(this._eventFactory());


         }else if(this.isBuffering){
          this.status = "buffering";


         }else if(this.status == "started" || (this.status == "playing" && pos != this._prevPos)){
          this.status = "playing";
          //this.onPosition(this._eventFactory());


         }else if(!this.isStopped && this.status == "playing" && pos == this._prevPos){
          this.status = "paused";
          console.warn("pause", pos, this._prevPos)
          if(this.status != this._prevStatus){
           this.onPause(this._eventFactory());
          }


         }else if((this.status == "paused" ||this.status == "stopped") && pos != this._prevPos){
          this.status = "started";
          this.onPlay(this._eventFactory());
         }
        }


        this._prevPos = pos;
        this._prevStatus = this.status;
        this.onStatus(this.status);
    • summary
      Calculate media status, based on playhead movement, and
      onStop and onStart events
      TODO:
      Figure in real status from the media for more accurate results.
  • dojox.av._Media._eventFactory

    • type
      Function
    • source: [view]
        var evt = {
         //position:this._channel.position,
         //seconds:this.toSeconds(this._channel.position*.001),
         //percentPlayed:this._getPercent(),
         status:this.status
        }
        return evt; // Object
    • summary
      Creates a generic event object.
    • returns
      Object
  • dojox.av._Media._sub

    • type
      Function
    • parameters:
      • topic: (typeof )
      • method: (typeof )
    • source: [view]
        dojo.subscribe(this.id+"/"+topic, this, method);
    • summary
      helper for subscribing to topics
  • dojox.av._Media._normalizeVolume

    • type
      Function
    • parameters:
      • vol: (typeof )
    • source: [view]
        if(vol>1){
         while(vol>1){
          vol*=.1
         }
        }
        return vol;
    • summary
      Ensures volume is less than one
  • dojox.av._Media._normalizeUrl

    • type
      Function
    • parameters:
      • _url: (typeof )
    • source: [view]
        console.log(" url:", _url);


        if(_url && (_url.toLowerCase().indexOf("http")<0 || _url.indexOf("/") == 0)){
         //
         // Appears to be a relative path. Attempt to convert it to absolute,
         // so it will better target the SWF.
         var loc = window.location.href.split("/");
         loc.pop();


         loc = loc.join("/")+"/";
         console.log(" loc:", loc);
         _url = loc+_url;
        }
        return _url;
    • summary
      Checks that path is relative to HTML file or
      convertes it to an absolute path.
  • dojox.av._Media.destroy

    • type
      Function
    • source: [view]
        if(!this.flashMedia){
         this._cons.push(dojo.connect(this, "onLoad", this, "destroy"));
         return;
        }
        dojo.forEach(this._subs, function(s){
         dojo.unsubscribe(s);
        });
        dojo.forEach(this._cons, function(c){
         dojo.disconnect(c);
        });
        this._flashObject.destroy();
        //dojo._destroyElement(this.flashDiv);
    • summary
      destroys flash
  • dojox.av._Media.status

    • summary
  • dojox.av._Media._positionHandle

    • summary
  • dojox.av._Media.duration

    • summary
  • dojox.av._Media.isBuffering

    • summary
  • dojox.av._Media._prevPos

    • summary
  • dojox.av._Media._prevStatus

    • summary
  • dojox.av

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary