Changeset 2040


Ignore:
Timestamp:
01/04/12 20:47:59 (17 months ago)
Author:
pablo
Message:

First pass at InStream API (644). Implements JavaScript API and Flash version

Location:
branches/fl5_instream
Files:
15 added
26 edited

Legend:

Unmodified
Added
Removed
  • branches/fl5_instream/build/build.xml

    r2032 r2040  
    250250                        <fileset dir="${basedir}/js/src/plugins" includes="jwplayer.plugins.js" /> 
    251251                        <fileset dir="${basedir}/js/src/plugins" includes="**/*.js" excludes="jwplayer.plugins.js" /> 
    252                         <fileset dir="${basedir}/js/src/api" includes="**/*.js" /> 
     252                        <fileset dir="${basedir}/js/src/api" includes="jwplayer.api.js" /> 
     253                        <fileset dir="${basedir}/js/src/api" includes="jwplayer.api.instream.js" /> 
    253254                        <fileset dir="${basedir}/js/src/embed" includes="jwplayer.embed.js" /> 
    254255                        <fileset dir="${basedir}/js/src/embed" includes="**/*.js" excludes="jwplayer.embed.js" /> 
  • branches/fl5_instream/js/bin-debug/jwplayer.js

    r2032 r2040  
    1919var $jw = jwplayer; 
    2020 
    21 jwplayer.version = '5.9.2032'; 
     21jwplayer.version = '5.9.2040'; 
    2222 
    2323// "Shiv" method for older IE browsers; required for parsing media tags 
     
    874874        } 
    875875         
     876        /* Normalizes differences between Flash and HTML5 internal players' event responses. */ 
     877        jwplayer.utils.translateEventResponse = function(type, eventProperties) { 
     878                var translated = jwplayer.utils.extend({}, eventProperties); 
     879                if (type == jwplayer.api.events.JWPLAYER_FULLSCREEN && !translated.fullscreen) { 
     880                        translated.fullscreen = translated.message == "true" ? true : false; 
     881                        delete translated.message; 
     882                } else if (typeof translated.data == "object") { 
     883                        // Takes ViewEvent "data" block and moves it up a level 
     884                        translated = jwplayer.utils.extend(translated, translated.data); 
     885                        delete translated.data; 
     886                } 
     887                 
     888                var rounders = ["position", "duration", "offset"]; 
     889                for (var rounder in rounders) { 
     890                        if (translated[rounders[rounder]]) { 
     891                                translated[rounders[rounder]] = Math.round(translated[rounders[rounder]] * 1000) / 1000; 
     892                        } 
     893                } 
     894                 
     895                return translated; 
     896        } 
    876897 
    877898})(jwplayer); 
     
    23122333                var _playerReady = false; 
    23132334                var _queuedCalls = []; 
     2335                var _instream = undefined; 
    23142336                 
    23152337                var _originalHTML = jwplayer.utils.getOuterHTML(container); 
     
    25372559                        return this; 
    25382560                }; 
     2561                this.loadInstream = function(item, instreamOptions) { 
     2562                        _instream = new jwplayer.api.instream(this, _player, item, instreamOptions); 
     2563                        return _instream; 
     2564                }; 
    25392565                // Player Events 
    25402566                this.onBufferChange = function(callback) { 
     
    27092735                this.dispatchEvent = function(type) { 
    27102736                        if (_listeners[type]) { 
    2711                                 var args = translateEventResponse(type, arguments[1]); 
     2737                                var args = _utils.translateEventResponse(type, arguments[1]); 
    27122738                                for (var l = 0; l < _listeners[type].length; l++) { 
    27132739                                        if (typeof _listeners[type][l] == 'function') { 
     
    27172743                        } 
    27182744                }; 
    2719                  
    2720                 function translateEventResponse(type, eventProperties) { 
    2721                         var translated = jwplayer.utils.extend({}, eventProperties); 
    2722                         if (type == jwplayer.api.events.JWPLAYER_FULLSCREEN && !translated.fullscreen) { 
    2723                                 translated.fullscreen = translated.message == "true" ? true : false; 
    2724                                 delete translated.message; 
    2725                         } else if (typeof translated.data == "object") { 
    2726                                 // Takes ViewEvent "data" block and moves it up a level 
    2727                                 translated = jwplayer.utils.extend(translated, translated.data); 
    2728                                 delete translated.data; 
    2729                         } 
    2730                          
    2731                         var rounders = ["position", "duration", "offset"]; 
    2732                         for (var rounder in rounders) { 
    2733                                 if (translated[rounders[rounder]]) { 
    2734                                         translated[rounders[rounder]] = Math.round(translated[rounders[rounder]] * 1000) / 1000; 
    2735                                 } 
    2736                         } 
    2737                          
    2738                         return translated; 
    2739                 } 
    2740                  
    2741                 this.callInternal = function(funcName, args) { 
     2745 
     2746                this.dispatchInstreamEvent = function(type) { 
     2747                        if (_instream) { 
     2748                                _instream.dispatchEvent(type, arguments); 
     2749                        } 
     2750                }; 
     2751 
     2752                this.callInternal = function() { 
    27422753                        /*this.callInternal = function() { 
    27432754                         var    funcName = arguments[0], 
     
    27462757                         args[argument] = arguments[argument]; 
    27472758                         }*/ 
     2759 
    27482760                        if (_playerReady) { 
     2761                                var funcName = arguments[0], 
     2762                                        args = []; 
     2763                                 
     2764                                for (var argument = 1; argument < arguments.length; argument++) { 
     2765                                         args.push(arguments[argument]); 
     2766                                } 
     2767                                 
    27492768                                if (typeof _player != "undefined" && typeof _player[funcName] == "function") { 
    2750                                         if (jwplayer.utils.exists(args)) { 
    2751                                                 //return (_player[funcName]).apply(this, args); 
    2752                                                 return (_player[funcName])(args); 
     2769                                        if (args.length == 2) {  
     2770                                                return (_player[funcName])(args[0], args[1]); 
     2771                                        } else if (args.length == 1) { 
     2772                                                return (_player[funcName])(args[0]); 
    27532773                                        } else { 
    27542774                                                return (_player[funcName])(); 
     
    28672887                JWPLAYER_PLAYER_STATE: 'jwplayerPlayerState', 
    28682888                JWPLAYER_PLAYLIST_LOADED: 'jwplayerPlaylistLoaded', 
    2869                 JWPLAYER_PLAYLIST_ITEM: 'jwplayerPlaylistItem' 
     2889                JWPLAYER_PLAYLIST_ITEM: 'jwplayerPlaylistItem', 
     2890                JWPLAYER_INSTREAM_CLICK: 'jwplayerInstreamClicked', 
     2891                JWPLAYER_INSTREAM_DESTROYED: 'jwplayerInstreamDestroyed' 
    28702892        }; 
    28712893         
     
    29502972        } 
    29512973}; 
     2974/** 
     2975 * InStream API  
     2976 *  
     2977 * @author Pablo 
     2978 * @version 5.9 
     2979 */ 
     2980(function(jwplayer) { 
     2981         
     2982        jwplayer.api.instream = function(api, player, item, options) { 
     2983                 
     2984                var _api = api; 
     2985                var _player = player; 
     2986                var _item = item; 
     2987                var _options = options; 
     2988                var _listeners = {}; 
     2989                var _stateListeners = {}; 
     2990                 
     2991                function _init() { 
     2992                        _api.callInternal("jwLoadInstream", item, options); 
     2993                } 
     2994                 
     2995                function _addInternalListener(player, type) { 
     2996                        _player.instream_jwAddEventListener(type, 'function(dat) { jwplayer("' + _api.id + '").dispatchInstreamEvent("' + type + '", dat); }'); 
     2997                }; 
     2998 
     2999                function _eventListener(type, callback) { 
     3000                        if (!_listeners[type]) { 
     3001                                _listeners[type] = []; 
     3002                                _addInternalListener(_player, type); 
     3003                        } 
     3004                        _listeners[type].push(callback); 
     3005                        return this; 
     3006                }; 
     3007 
     3008                function _stateListener(state, callback) { 
     3009                        if (!_stateListeners[state]) { 
     3010                                _stateListeners[state] = []; 
     3011                                _eventListener(jwplayer.api.events.JWPLAYER_PLAYER_STATE, _stateCallback(state)); 
     3012                        } 
     3013                        _stateListeners[state].push(callback); 
     3014                        return this; 
     3015                }; 
     3016 
     3017                function _stateCallback(state) { 
     3018                        return function(args) { 
     3019                                var newstate = args.newstate, oldstate = args.oldstate; 
     3020                                if (newstate == state) { 
     3021                                        var callbacks = _stateListeners[newstate]; 
     3022                                        if (callbacks) { 
     3023                                                for (var c = 0; c < callbacks.length; c++) { 
     3024                                                        if (typeof callbacks[c] == 'function') { 
     3025                                                                callbacks[c].call(this, { 
     3026                                                                        oldstate: oldstate, 
     3027                                                                        newstate: newstate, 
     3028                                                                        type: args.type 
     3029                                                                }); 
     3030                                                        } 
     3031                                                } 
     3032                                        } 
     3033                                } 
     3034                        }; 
     3035                }                
     3036                this.dispatchEvent = function(type, calledArguments) { 
     3037                        if (_listeners[type]) { 
     3038                                var args = _utils.translateEventResponse(type, calledArguments[1]); 
     3039                                for (var l = 0; l < _listeners[type].length; l++) { 
     3040                                        if (typeof _listeners[type][l] == 'function') { 
     3041                                                _listeners[type][l].call(this, args); 
     3042                                        } 
     3043                                } 
     3044                        } 
     3045                } 
     3046                 
     3047                 
     3048                this.onError = function(callback) { 
     3049                        return _eventListener(jwplayer.api.events.JWPLAYER_ERROR, callback); 
     3050                }; 
     3051                this.onFullscreen = function(callback) { 
     3052                        return _eventListener(jwplayer.api.events.JWPLAYER_FULLSCREEN, callback); 
     3053                }; 
     3054                this.onMeta = function(callback) { 
     3055                        return _eventListener(jwplayer.api.events.JWPLAYER_MEDIA_META, callback); 
     3056                }; 
     3057                this.onMute = function(callback) { 
     3058                        return _eventListener(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, callback); 
     3059                }; 
     3060                this.onComplete = function(callback) { 
     3061                        return _eventListener(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE, callback); 
     3062                }; 
     3063                this.onSeek = function(callback) { 
     3064                        return _eventListener(jwplayer.api.events.JWPLAYER_MEDIA_SEEK, callback); 
     3065                }; 
     3066                this.onTime = function(callback) { 
     3067                        return _eventListener(jwplayer.api.events.JWPLAYER_MEDIA_TIME, callback); 
     3068                }; 
     3069                this.onVolume = function(callback) { 
     3070                        return _eventListener(jwplayer.api.events.JWPLAYER_MEDIA_VOLUME, callback); 
     3071                }; 
     3072                // State events 
     3073                this.onBuffer = function(callback) { 
     3074                        return _stateListener(jwplayer.api.events.state.BUFFERING, callback); 
     3075                }; 
     3076                this.onPause = function(callback) { 
     3077                        return _stateListener(jwplayer.api.events.state.PAUSED, callback); 
     3078                }; 
     3079                this.onPlay = function(callback) { 
     3080                        return _stateListener(jwplayer.api.events.state.PLAYING, callback); 
     3081                }; 
     3082                this.onIdle = function(callback) { 
     3083                        return _stateListener(jwplayer.api.events.state.IDLE, callback); 
     3084                }; 
     3085                // Instream events 
     3086                this.onInstreamClick = function(callback) { 
     3087                        return _eventListener(jwplayer.api.events.JWPLAYER_INSTREAM_CLICK, callback); 
     3088                }; 
     3089                this.onInstreamDestroyed = function(callback) { 
     3090                        return _eventListener(jwplayer.api.events.JWPLAYER_INSTREAM_DESTROYED, callback); 
     3091                }; 
     3092                 
     3093                this.play = function(state) { 
     3094                        _player.instream_jwPlay(state); 
     3095                }; 
     3096                this.pause= function(state) { 
     3097                        _player.instream_jwPause(state); 
     3098                }; 
     3099                this.seek = function(pos) { 
     3100                        _player.instream_jwSeek(pos); 
     3101                }; 
     3102                this.destroy = function() { 
     3103                        _player.instream_jwDestroy(); 
     3104                }; 
     3105                this.getState = function() { 
     3106                        return _player.instream_jwGetState(); 
     3107                } 
     3108                this.getDuration = function() { 
     3109                        return _player.instream_jwGetDuration(); 
     3110                } 
     3111                this.getPosition = function() { 
     3112                        return _player.instream_jwGetPosition(); 
     3113                } 
     3114 
     3115                _init(); 
     3116                 
     3117                 
     3118        } 
     3119         
     3120})(jwplayer); 
     3121 
    29523122/** 
    29533123 * Embedder for the JW Player 
     
    37333903                        var providers = ["video", "http", "sound", "image"]; 
    37343904                        // Provider is set, and is not video, http, sound, image - play in Flash 
    3735                         if (provider && (providers.toString().indexOf(provider < 0))) { 
     3905                        if (provider && (providers.toString().indexOf(provider) < 0) ) { 
    37363906                                return true; 
    37373907                        } 
  • branches/fl5_instream/js/src/api/jwplayer.api.js

    r2032 r2040  
    1919                var _playerReady = false; 
    2020                var _queuedCalls = []; 
     21                var _instream = undefined; 
    2122                 
    2223                var _originalHTML = jwplayer.utils.getOuterHTML(container); 
     
    244245                        return this; 
    245246                }; 
     247                this.loadInstream = function(item, instreamOptions) { 
     248                        _instream = new jwplayer.api.instream(this, _player, item, instreamOptions); 
     249                        return _instream; 
     250                }; 
    246251                // Player Events 
    247252                this.onBufferChange = function(callback) { 
     
    416421                this.dispatchEvent = function(type) { 
    417422                        if (_listeners[type]) { 
    418                                 var args = translateEventResponse(type, arguments[1]); 
     423                                var args = _utils.translateEventResponse(type, arguments[1]); 
    419424                                for (var l = 0; l < _listeners[type].length; l++) { 
    420425                                        if (typeof _listeners[type][l] == 'function') { 
     
    424429                        } 
    425430                }; 
    426                  
    427                 function translateEventResponse(type, eventProperties) { 
    428                         var translated = jwplayer.utils.extend({}, eventProperties); 
    429                         if (type == jwplayer.api.events.JWPLAYER_FULLSCREEN && !translated.fullscreen) { 
    430                                 translated.fullscreen = translated.message == "true" ? true : false; 
    431                                 delete translated.message; 
    432                         } else if (typeof translated.data == "object") { 
    433                                 // Takes ViewEvent "data" block and moves it up a level 
    434                                 translated = jwplayer.utils.extend(translated, translated.data); 
    435                                 delete translated.data; 
    436                         } 
    437                          
    438                         var rounders = ["position", "duration", "offset"]; 
    439                         for (var rounder in rounders) { 
    440                                 if (translated[rounders[rounder]]) { 
    441                                         translated[rounders[rounder]] = Math.round(translated[rounders[rounder]] * 1000) / 1000; 
    442                                 } 
    443                         } 
    444                          
    445                         return translated; 
    446                 } 
    447                  
    448                 this.callInternal = function(funcName, args) { 
     431 
     432                this.dispatchInstreamEvent = function(type) { 
     433                        if (_instream) { 
     434                                _instream.dispatchEvent(type, arguments); 
     435                        } 
     436                }; 
     437 
     438                this.callInternal = function() { 
    449439                        /*this.callInternal = function() { 
    450440                         var    funcName = arguments[0], 
     
    453443                         args[argument] = arguments[argument]; 
    454444                         }*/ 
     445 
    455446                        if (_playerReady) { 
     447                                var funcName = arguments[0], 
     448                                        args = []; 
     449                                 
     450                                for (var argument = 1; argument < arguments.length; argument++) { 
     451                                         args.push(arguments[argument]); 
     452                                } 
     453                                 
    456454                                if (typeof _player != "undefined" && typeof _player[funcName] == "function") { 
    457                                         if (jwplayer.utils.exists(args)) { 
    458                                                 //return (_player[funcName]).apply(this, args); 
    459                                                 return (_player[funcName])(args); 
     455                                        if (args.length == 2) {  
     456                                                return (_player[funcName])(args[0], args[1]); 
     457                                        } else if (args.length == 1) { 
     458                                                return (_player[funcName])(args[0]); 
    460459                                        } else { 
    461460                                                return (_player[funcName])(); 
     
    574573                JWPLAYER_PLAYER_STATE: 'jwplayerPlayerState', 
    575574                JWPLAYER_PLAYLIST_LOADED: 'jwplayerPlaylistLoaded', 
    576                 JWPLAYER_PLAYLIST_ITEM: 'jwplayerPlaylistItem' 
     575                JWPLAYER_PLAYLIST_ITEM: 'jwplayerPlaylistItem', 
     576                JWPLAYER_INSTREAM_CLICK: 'jwplayerInstreamClicked', 
     577                JWPLAYER_INSTREAM_DESTROYED: 'jwplayerInstreamDestroyed' 
    577578        }; 
    578579         
  • branches/fl5_instream/js/src/embed/jwplayer.embed.flash.js

    r1799 r2040  
    238238                        var providers = ["video", "http", "sound", "image"]; 
    239239                        // Provider is set, and is not video, http, sound, image - play in Flash 
    240                         if (provider && (providers.toString().indexOf(provider < 0))) { 
     240                        if (provider && (providers.toString().indexOf(provider) < 0) ) { 
    241241                                return true; 
    242242                        } 
  • branches/fl5_instream/js/src/jwplayer.js

    r2032 r2040  
    1111var $jw = jwplayer; 
    1212 
    13 jwplayer.version = '5.9.2032'; 
     13jwplayer.version = '5.9.2040'; 
    1414 
    1515// "Shiv" method for older IE browsers; required for parsing media tags 
  • branches/fl5_instream/js/src/utils/jwplayer.utils.js

    r2011 r2040  
    849849        } 
    850850         
     851        /* Normalizes differences between Flash and HTML5 internal players' event responses. */ 
     852        jwplayer.utils.translateEventResponse = function(type, eventProperties) { 
     853                var translated = jwplayer.utils.extend({}, eventProperties); 
     854                if (type == jwplayer.api.events.JWPLAYER_FULLSCREEN && !translated.fullscreen) { 
     855                        translated.fullscreen = translated.message == "true" ? true : false; 
     856                        delete translated.message; 
     857                } else if (typeof translated.data == "object") { 
     858                        // Takes ViewEvent "data" block and moves it up a level 
     859                        translated = jwplayer.utils.extend(translated, translated.data); 
     860                        delete translated.data; 
     861                } 
     862                 
     863                var rounders = ["position", "duration", "offset"]; 
     864                for (var rounder in rounders) { 
     865                        if (translated[rounders[rounder]]) { 
     866                                translated[rounders[rounder]] = Math.round(translated[rounders[rounder]] * 1000) / 1000; 
     867                        } 
     868                } 
     869                 
     870                return translated; 
     871        } 
    851872 
    852873})(jwplayer); 
  • branches/fl5_instream/js/test/examples/index.html

    r2032 r2040  
    200200                        "Player 5.9": { 
    201201                        "Features": { 
    202                                 "onBeforePlay Event": "onbeforeplay.html" 
     202                                "onBeforePlay Event": "onbeforeplay.html", 
     203                                "InStream API": "instream.html" 
    203204                        } 
    204205                } 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/controller/Controller.as

    r2032 r2040  
    8585                /** Load after unlock - My favorite variable ever **/ 
    8686                protected var _unlockAndLoad:Boolean; 
     87                /** The lock swallowed the complete action; we should go to the next playlist item if necessary **/ 
     88                protected var _completeOnUnlock:Boolean; 
    8789                /** Whether the playlist has been loaded yet **/ 
    8890                protected var _playlistReady:Boolean = false; 
     
    229231                protected function playlistItemHandler(evt:PlaylistEvent):void { 
    230232                        _model.config.item = _model.playlist.currentIndex; 
     233                        _interruptPlay = false; 
    231234                        load(_model.playlist.currentItem); 
    232235                } 
     
    245248 
    246249 
    247                 protected function completeHandler(evt:MediaEvent):void { 
     250                protected function completeHandler(evt:MediaEvent=null):void { 
     251                        if (locking) { 
     252                                _completeOnUnlock = true; 
     253                                return; 
     254                        } 
     255                         
    248256                        switch (_model.config.repeat) { 
    249257                                case RepeatOptions.SINGLE: 
     
    287295                        if (_lockManager.lock(plugin, callback)) { 
    288296                                // If it was playing, pause playback and plan to resume when you're done 
    289                                 if (_player.state == PlayerState.PLAYING || _player.state == PlayerState.BUFFERING || _preplay) { 
     297                                if (_player.state == PlayerState.PLAYING || _player.state == PlayerState.BUFFERING || _preplay || continueOnRepeat) { 
    290298                                        if (!_preplay) { 
    291299                                                _model.media.pause();    
    292300                                        } 
    293301                                        _lockingResume = true; 
    294                                 } 
     302                                        _interruptPlay = false; 
     303                                } else { 
     304                                        _interruptPlay = true; 
     305                                } 
     306                                 
    295307                                 
    296308                                // Tell everyone you're locked 
     
    317329                                } 
    318330                                if (!locking) { 
    319                                         if (_unlockAndLoad) { 
     331                                        if (_completeOnUnlock) { 
     332                                                _completeOnUnlock = false; 
     333                                                completeHandler(); 
     334                                                _interruptPlay = false; 
     335                                                return true; 
     336                                        } else if (_unlockAndLoad) { 
    320337                                                load(_player.playlist.currentItem); 
    321338                                                _unlockAndLoad = false; 
     
    328345                                                } 
    329346                                        } 
     347                                        _interruptPlay = false; 
    330348                                        return true; 
    331349                                } 
     
    336354 
    337355                public function setVolume(vol:Number):Boolean { 
    338                         if (locking) { 
    339                                 return false; 
    340                         } 
     356/*                      if (locking) { 
     357                                return false; 
     358                        } 
     359*/ 
    341360                        if (_model.media) { 
    342361                                mute(false);  
     
    351370 
    352371                public function mute(muted:Boolean):Boolean { 
    353                         if (locking) { 
    354                                 return false; 
    355                         } 
     372/*                      if (locking) { 
     373                                return false; 
     374                        } 
     375*/ 
    356376                        if (muted && !_model.mute) { 
    357377                                _model.mute = true; 
     
    370390                        if (!_preplay) { 
    371391                                _preplay = true; 
    372                                 dispatchEvent(new PlayerEvent(MediaEvent.JWPLAYER_MEDIA_BEFOREPLAY)); 
     392                                dispatchEvent(new MediaEvent(MediaEvent.JWPLAYER_MEDIA_BEFOREPLAY)); 
    373393                                _preplay = false; 
    374394                                if (_interruptPlay) { 
     
    512532                                stop(); 
    513533                                _player.playlist.currentIndex = index; 
     534                                _interruptPlay = false; 
    514535                                play(); 
    515536                                return true; 
     
    720741                        Configger.saveCookie(name, value); 
    721742                } 
     743                 
     744                protected function get continueOnRepeat():Boolean { 
     745                        return (_model.config.repeat != RepeatOptions.NONE); 
     746                } 
    722747 
    723748        } 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/controller/PlayerSetup.as

    r1794 r2040  
    66        import com.longtailvideo.jwplayer.player.IPlayer; 
    77        import com.longtailvideo.jwplayer.plugins.IPlugin; 
     8        import com.longtailvideo.jwplayer.plugins.InStreamAdPlugin; 
    89        import com.longtailvideo.jwplayer.plugins.PluginConfig; 
    910        import com.longtailvideo.jwplayer.plugins.V4Plugin; 
     
    223224                        // Compiled in plugins go here.  Example: 
    224225                        // _view.addPlugin("test", new TestPlugin()); 
     226                        //_view.addPlugin("instreamads", new InStreamAdPlugin()); 
    225227                } 
    226228 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/events/MediaEvent.as

    r2032 r2040  
    176176                 */ 
    177177                public static var JWPLAYER_MEDIA_BEFOREPLAY:String = "jwplayerMediaBeforePlay"; 
    178  
     178                /** 
     179                 * The MediaEvent.JWPLAYER_MEDIA_BEFORECOMPLETE constant defines the value of the 
     180                 * <code>type</code> property of the event object 
     181                 * for a <code>jwplayerMediaBeforeComplete</code> event. 
     182                 * 
     183                 * <table class="innertable"> 
     184                 *              <tr><th>Property</th><th>Value</th></tr> 
     185                 *              <tr><td><code>id</code></td><td>ID of the player in the HTML DOM. Used by javascript to reference the player.</td></tr> 
     186                 *              <tr><td><code>client</code></td><td>A string representing the client the player runs in (e.g. FLASH WIN 9,0,115,0).</td></tr> 
     187                 *              <tr><td><code>version</code></td><td>A string representing the major version, minor version and revision number of the player (e.g. 5.0.395).</td></tr> 
     188                 * </table> 
     189                 *  
     190                 * @eventType jwplayerMediaBeforePlay 
     191                 */ 
     192                public static var JWPLAYER_MEDIA_BEFORECOMPLETE:String = "jwplayerMediaBeforeComplete"; 
    179193                /** 
    180194             *  The <code>MediaEvent.JWPLAYER_MEDIA_MUTE</code> constant defines the value of the  
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/model/Model.as

    r2032 r2040  
    212212                protected function forwardEvents(evt:Event):void { 
    213213                        if (evt is PlayerEvent) { 
    214                                 if (evt.type == MediaEvent.JWPLAYER_MEDIA_ERROR) { 
     214                                if (evt.type == MediaEvent.JWPLAYER_MEDIA_COMPLETE) { 
     215                                        dispatchEvent(new MediaEvent(MediaEvent.JWPLAYER_MEDIA_BEFORECOMPLETE)); 
     216                                } else if (evt.type == MediaEvent.JWPLAYER_MEDIA_ERROR) { 
    215217                                        // Translate media error into player error. 
    216218                                        dispatchEvent(new PlayerEvent(PlayerEvent.JWPLAYER_ERROR, (evt as MediaEvent).message)); 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/model/PlayerConfig.as

    r1858 r2040  
    388388                } 
    389389                 
     390                /** 
     391                 * Overwrites a plugin's configuration.  Use with caution. 
     392                 **/ 
     393                public function setPluginConfig(pluginId:String, pluginConfig:PluginConfig):void { 
     394                        if (pluginId && pluginConfig) { 
     395                                _pluginConfig[pluginId] = pluginConfig; 
     396                        } 
     397                } 
     398                 
    390399                /** A list of available pluginConfig keys. **/ 
    391400                public function get pluginIds():Array { 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/player/IPlayer.as

    r1246 r2040  
    11package com.longtailvideo.jwplayer.player { 
    22        import com.longtailvideo.jwplayer.events.IGlobalEventDispatcher; 
     3        import com.longtailvideo.jwplayer.model.IInstreamOptions; 
    34        import com.longtailvideo.jwplayer.model.IPlaylist; 
    45        import com.longtailvideo.jwplayer.model.PlayerConfig; 
     6        import com.longtailvideo.jwplayer.model.PlaylistItem; 
    57        import com.longtailvideo.jwplayer.plugins.IPlugin; 
    68        import com.longtailvideo.jwplayer.view.IPlayerComponents; 
     
    7375                function get controls():IPlayerComponents; 
    7476                function overrideComponent(plugin:IPlayerComponent):void; 
     77                function loadInstream(target:IPlugin, item:PlaylistItem, options:IInstreamOptions=null):IInstreamPlayer; 
    7578        } 
    7679} 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/player/JavascriptAPI.as

    r2032 r2040  
    11package com.longtailvideo.jwplayer.player { 
    22        import com.longtailvideo.jwplayer.events.ComponentEvent; 
     3        import com.longtailvideo.jwplayer.events.InstreamEvent; 
    34        import com.longtailvideo.jwplayer.events.MediaEvent; 
    45        import com.longtailvideo.jwplayer.events.PlayerEvent; 
     
    67        import com.longtailvideo.jwplayer.events.PlaylistEvent; 
    78        import com.longtailvideo.jwplayer.events.ViewEvent; 
     9        import com.longtailvideo.jwplayer.model.IInstreamOptions; 
     10        import com.longtailvideo.jwplayer.model.InstreamOptions; 
    811        import com.longtailvideo.jwplayer.model.Playlist; 
     12        import com.longtailvideo.jwplayer.model.PlaylistItem; 
     13        import com.longtailvideo.jwplayer.plugins.AbstractPlugin; 
     14        import com.longtailvideo.jwplayer.plugins.IPlugin; 
    915        import com.longtailvideo.jwplayer.utils.JavascriptSerialization; 
    1016        import com.longtailvideo.jwplayer.utils.Logger; 
     
    3036                protected var _listeners:Object; 
    3137                protected var _queuedEvents:Array = []; 
    32  
     38                 
     39                protected var _lockPlugin:IPlugin; 
     40                protected var _instream:IInstreamPlayer; 
     41                protected var _isItem:PlaylistItem; 
     42                protected var _isConfig:IInstreamOptions; 
    3343                 
    3444                public function JavascriptAPI(player:IPlayer) { 
    3545                        _listeners = {}; 
     46                        _lockPlugin = new AbstractPlugin(); 
    3647                         
    3748                        _player = player; 
     
    144155                                ExternalInterface.addCallback("jwDockShow", js_showDock); 
    145156                                 
     157                                // Instream API 
     158                                ExternalInterface.addCallback("jwLoadInstream", js_loadInstream); 
     159                                 
    146160                                // UNIMPLEMENTED 
    147161                                //ExternalInterface.addCallback("jwGetBandwidth", js_getBandwidth);  
     
    453467                } 
    454468                 
     469                protected function js_loadInstream(item:Object, config:Object):void { 
     470                        _isItem = new PlaylistItem(item); 
     471                        _isConfig = new InstreamOptions(config); 
     472 
     473                        if (!_isConfig.autoload) { 
     474                                _player.lock(_lockPlugin, function():void { 
     475                                        _instream = _player.loadInstream(_lockPlugin, _isItem, _isConfig); 
     476                                        beginInstream(); 
     477                                }); 
     478                        } else { 
     479                                _instream = _player.loadInstream(_lockPlugin, _isItem, _isConfig); 
     480                                beginInstream(); 
     481                        } 
     482                } 
     483                 
     484                protected function beginInstream():void { 
     485                        if (_instream) { 
     486                                _instream.addEventListener(InstreamEvent.JWPLAYER_INSTREAM_DESTROYED, function(evt:InstreamEvent):void { 
     487                                        _player.unlock(_lockPlugin); 
     488                                }); 
     489                                new JavascriptInstreamAPI(_instream, _isConfig, _player, _lockPlugin);   
     490                        }        
     491                } 
     492                 
    455493                protected function setComponentVisibility(component:IPlayerComponent, state:Boolean):void { 
    456494                        state ? component.show() : component.hide(); 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/player/Player.as

    r1228 r2040  
    44        import com.longtailvideo.jwplayer.events.IGlobalEventDispatcher; 
    55        import com.longtailvideo.jwplayer.events.PlayerEvent; 
     6        import com.longtailvideo.jwplayer.model.IInstreamOptions; 
    67        import com.longtailvideo.jwplayer.model.IPlaylist; 
    78        import com.longtailvideo.jwplayer.model.Model; 
    89        import com.longtailvideo.jwplayer.model.PlayerConfig; 
     10        import com.longtailvideo.jwplayer.model.PlaylistItem; 
    911        import com.longtailvideo.jwplayer.plugins.IPlugin; 
    1012        import com.longtailvideo.jwplayer.utils.Logger; 
     
    279281                        return view.getPlugin(id); 
    280282                }  
     283                 
     284                /** 
     285                 * @inheritDoc 
     286                 **/ 
     287                public function loadInstream(target:IPlugin, item:PlaylistItem, options:IInstreamOptions=null):IInstreamPlayer { 
     288                        var instream:IInstreamPlayer = new InstreamPlayer(target, item, options, model, view, controller); 
     289                        return instream; 
     290                } 
    281291 
    282292                /** The player should not accept any calls referencing its display stack **/ 
     
    300310                } 
    301311                 
    302                  
    303312                ///////////////////////////////////////////              
    304313                /// IGlobalEventDispatcher implementation 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/player/PlayerVersion.as

    r2032 r2040  
    33         
    44        public class PlayerVersion { 
    5                 protected static var _version:String = '5.9.2032'; 
     5                protected static var _version:String = '5.9.2040'; 
    66                 
    77                public static function get version():String { 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/utils/Animations.as

    r1965 r2040  
    22        import flash.display.MovieClip; 
    33        import flash.events.Event; 
     4        import flash.events.EventDispatcher; 
    45         
    56         
     7        /** 
     8         * Fired when an animation has completed 
     9         * 
     10         * @eventType flash.events.Event.COMPLETE 
     11         */ 
     12        [Event(name="complete", type="flash.events.Event")] 
    613         
    7         public class Animations { 
     14        public class Animations extends EventDispatcher { 
    815                /** Target MovieClip **/ 
    916                private var _tgt:MovieClip; 
     
    5158                                        _tgt.visible = false; 
    5259                                } 
     60                                dispatchEvent(new Event(Event.COMPLETE)); 
    5361                        } else { 
    5462                                _tgt.visible = true; 
     
    8795                                _tgt.x = _xps; 
    8896                                _tgt.y = _yps; 
     97                                dispatchEvent(new Event(Event.COMPLETE)); 
    8998                        } else { 
    9099                                _tgt.x = _xps - (_xps - _tgt.x) / _spd; 
     
    115124                                _tgt.tf.htmlText = _str; 
    116125                                _tgt.removeEventListener(Event.ENTER_FRAME, easeHandler); 
     126                                dispatchEvent(new Event(Event.COMPLETE)); 
    117127                        } 
    118128                } 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/utils/DisplayObjectUtils.as

    r637 r2040  
    11package com.longtailvideo.jwplayer.utils { 
     2        import flash.display.DisplayObject; 
    23        import flash.display.DisplayObjectContainer; 
    3         import flash.display.DisplayObject; 
     4        import flash.geom.Rectangle; 
    45        import flash.utils.getQualifiedClassName; 
    56         
     
    3839                } 
    3940 
     41                 
     42                /** 
     43                 * duplicateDisplayObject 
     44                 *  
     45                 * see: http://www.kirupa.com/forum/showthread.php?223798-ActionScript-3-Tip-of-the-Day/page12&p=1939827#172  
     46                 *  
     47                 * creates a duplicate of the DisplayObject passed. 
     48                 * similar to duplicateMovieClip in AVM1 
     49                 * @param target the display object to duplicate 
     50                 * @param autoAdd if true, adds the duplicate to the display list 
     51                 * in which target was located 
     52                 * @return a duplicate instance of target 
     53                 */ 
     54                public static function duplicateDisplayObject(target:DisplayObject, autoAdd:Boolean = false):DisplayObject { 
     55                        // create duplicate 
     56                        var targetClass:Class = Object(target).constructor; 
     57                        var duplicate:DisplayObject = new targetClass(); 
     58                         
     59                        // duplicate properties 
     60                        duplicate.transform = target.transform; 
     61                        duplicate.filters = target.filters; 
     62                        duplicate.cacheAsBitmap = target.cacheAsBitmap; 
     63                        duplicate.opaqueBackground = target.opaqueBackground; 
     64                        if (target.scale9Grid) { 
     65                                var rect:Rectangle = target.scale9Grid; 
     66                                // WAS Flash 9 bug where returned scale9Grid is 20x larger than assigned 
     67                                // rect.x /= 20, rect.y /= 20, rect.width /= 20, rect.height /= 20; 
     68                                duplicate.scale9Grid = rect; 
     69                        } 
     70                         
     71                        // add to target parent's display list 
     72                        // if autoAdd was provided as true 
     73                        if (autoAdd && target.parent) { 
     74                                target.parent.addChild(duplicate); 
     75                        } 
     76                        return duplicate; 
     77                } 
     78                 
     79                 
    4080        } 
    4181} 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/utils/JavascriptSerialization.as

    r1824 r2040  
    6868                                                var newkey:String = key.replace(".", "__dot__"); 
    6969                                                newkey = newkey.replace("-", "_"); 
     70                                                newkey = newkey.replace(/[^A-Za-z0-9\_]/g, ""); 
    7071                                                newObj[newkey] = stripDots(obj[key]); 
    7172                                        } 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/utils/Stacker.as

    r1459 r2040  
    2121         **/ 
    2222        public function Stacker(clp:MovieClip):void { 
    23             clip = clp; 
    24             analyze(); 
     23                        if (clp is MovieClip) { 
     24                    clip = clp; 
     25                analyze(); 
     26                        } else { 
     27                                throw new TypeError("Expecting a MovieClip"); 
     28                        } 
    2529        } 
    2630 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/view/View.as

    r1942 r2040  
    1515        import com.longtailvideo.jwplayer.plugins.IPlugin; 
    1616        import com.longtailvideo.jwplayer.plugins.PluginConfig; 
     17        import com.longtailvideo.jwplayer.utils.Animations; 
    1718        import com.longtailvideo.jwplayer.utils.Draw; 
    1819        import com.longtailvideo.jwplayer.utils.Logger; 
     
    6667                protected var _pluginsLayer:MovieClip; 
    6768                protected var _plugins:Object; 
    68  
     69                protected var _instreamLayer:MovieClip; 
     70                protected var _instreamPlugin:IPlugin; 
     71                protected var _instreamAnim:Animations; 
     72                 
    6973                protected var _displayMasker:MovieClip; 
    70  
     74                protected var _instreamMasker:MovieClip; 
     75                 
    7176                protected var _image:Loader; 
    7277                protected var _logo:Logo; 
     
    271276                        _plugins = {}; 
    272277                         
     278                        _instreamLayer = setupLayer("instream", currentLayer++); 
     279                        _instreamLayer.alpha = 0; 
     280                        _instreamLayer.visible = false; 
     281                        _instreamAnim = new Animations(_instreamLayer); 
     282                        _instreamAnim.addEventListener(Event.COMPLETE, instreamAnimationComplete); 
    273283                } 
    274284                         
     
    313323 
    314324                        _maskedLayers.mask = _displayMasker; 
     325                         
     326                        _instreamMasker = new MovieClip(); 
     327                        _instreamMasker.graphics.beginFill(0x000000, 1); 
     328                        _instreamMasker.graphics.drawRect(0, 0, _player.config.width, _player.config.height); 
     329                        _instreamMasker.graphics.endFill(); 
     330                         
     331                        _instreamLayer.mask = _instreamMasker; 
    315332                } 
    316333 
     
    340357                                dispatchEvent(new ViewEvent(ViewEvent.JWPLAYER_VIEW_FULLSCREEN, _fullscreen)); 
    341358                        } 
     359                        redraw(); 
     360                         
    342361                        dispatchEvent(new ViewEvent(ViewEvent.JWPLAYER_RESIZE, {width: RootReference.stage.stageWidth, height: RootReference.stage.stageHeight})); 
    343  
    344                         redraw(); 
    345362                } 
    346363 
     
    471488                        _displayMasker.graphics.drawRect(_components.display.x, _components.display.y, _player.config.width, _player.config.height); 
    472489                        _displayMasker.graphics.endFill(); 
     490 
     491                        _instreamMasker.graphics.clear(); 
     492                        _instreamMasker.graphics.beginFill(0, 1); 
     493                        _instreamMasker.graphics.drawRect(_components.display.x, _components.display.y, _player.config.width, _player.config.height); 
     494                        _instreamMasker.graphics.endFill(); 
    473495                } 
    474496 
     
    604626                } 
    605627                 
     628                public function setupInstream(_instreamDisplay:DisplayObject, plugin:IPlugin):void { 
     629                        _instreamPlugin = plugin; 
     630                        if (_instreamDisplay) { 
     631                                _instreamLayer.addChild(_instreamDisplay); 
     632                        } 
     633                        try { 
     634                                var pluginDO:DisplayObject = plugin as DisplayObject; 
     635                                if (pluginDO) { 
     636                                        _pluginsLayer.removeChild(pluginDO); 
     637                                        _instreamLayer.addChild(pluginDO); 
     638                                } 
     639                        } catch(e:Error) { 
     640                                Logger.log("Could not add instream plugin to display stack"); 
     641                        } 
     642                         
     643                        _instreamAnim.fade(1); 
     644                } 
     645                 
     646                public function destroyInstream():void { 
     647                        if (_instreamPlugin && _instreamPlugin is DisplayObject) { 
     648                                _pluginsLayer.addChild(_instreamPlugin as DisplayObject); 
     649                        } 
     650                        _instreamAnim.fade(0); 
     651                } 
     652                 
     653                protected function instreamAnimationComplete(evt:Event):void { 
     654                        if (_instreamLayer.alpha == 0) { 
     655                                while(_instreamLayer.numChildren > 0) { 
     656                                        _instreamLayer.removeChildAt(0); 
     657                                } 
     658                                _instreamPlugin = null; 
     659                        } 
     660                } 
     661                 
    606662        } 
    607663} 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/view/components/ControlbarComponentV4.as

    r1994 r2040  
    1010        import com.longtailvideo.jwplayer.plugins.PluginConfig; 
    1111        import com.longtailvideo.jwplayer.utils.Animations; 
     12        import com.longtailvideo.jwplayer.utils.DisplayObjectUtils; 
    1213        import com.longtailvideo.jwplayer.utils.Draw; 
    1314        import com.longtailvideo.jwplayer.utils.Logger; 
     
    3031        import flash.ui.Mouse; 
    3132        import flash.utils.clearTimeout; 
     33        import flash.utils.getDefinitionByName; 
     34        import flash.utils.getQualifiedClassName; 
    3235        import flash.utils.setTimeout; 
    3336         
    3437        public class ControlbarComponentV4 extends CoreComponent implements IControlbarComponent { 
    3538                /** Reference to the original skin **/ 
    36                 private var skin:Sprite; 
     39                private var skin:*; 
    3740                /** A list with all controls. **/ 
    3841                private var stacker:Stacker; 
     
    8184                                        unmuteButton: ViewEvent.JWPLAYER_VIEW_MUTE}; 
    8285                        skin = _player.skin.getSWFSkin().getChildByName('controlbar') as Sprite; 
     86                        if (!skin) { 
     87                                var clip:DisplayObject = Draw.clone(_player.skin.getSWFSkin()['controlbar'], false); 
     88                                if (clip is Sprite) { 
     89                                        skin = clip as Sprite; 
     90                                } 
     91                                stacker = new Stacker(skin); 
     92                        } else { 
     93                                stacker = new Stacker(skin as MovieClip); 
     94                        } 
    8395                        skin.x = 0; 
    8496                        skin.y = 0; 
     
    97109                        RootReference.stage.addEventListener(MouseEvent.MOUSE_MOVE, moveHandler); 
    98110                        RootReference.stage.addEventListener(KeyboardEvent.KEY_DOWN, moveHandler); 
    99                         stacker = new Stacker(skin as MovieClip); 
    100111                        try { 
    101112                                getSkinComponent("linkButton").visible = false; 
     
    182193                                getSkinComponent('fullscreenButton').visible = false; 
    183194                                getSkinComponent('normalscreenButton').visible = false; 
    184                                 if (stage['displayState'] && _player.config.height > 40) { 
     195                                if (RootReference.stage['displayState'] && _player.config.height > 40) { 
    185196                                        if (_player.config.fullscreen) { 
    186197                                                getSkinComponent('fullscreenButton').visible = false; 
     
    572583                        var sliderType:String = scrubber.name; 
    573584 
    574                         stage.removeEventListener(MouseEvent.MOUSE_UP, upHandler); 
     585                        RootReference.stage.removeEventListener(MouseEvent.MOUSE_UP, upHandler); 
    575586                        scrubber.icon.stopDrag(); 
    576587                        if (sliderType == 'timeSlider' && _player.playlist && _player.playlist.currentItem) { 
     
    602613 
    603614                private function getSkinComponent(element:String):DisplayObject { 
    604                         return skin.getChildByName(element) as DisplayObject; 
     615                        var component:DisplayObject = skin.getChildByName(element) as DisplayObject; 
     616                        if (component) { 
     617                                return component; 
     618                        } else if (skin[element]) { 
     619                                return Draw.clone(skin[element], false); 
     620                        } 
     621                        return null; 
    605622                } 
    606623 
    607624 
    608625                private function getSkinElementChild(element:String, child:String):DisplayObject { 
    609                         return (skin.getChildByName(element) as MovieClip).getChildByName(child); 
     626                        var clip:DisplayObject = (skin.getChildByName(element) as MovieClip).getChildByName(child); 
     627                        if (clip) { 
     628                                return clip; 
     629                        } else if (skin[element] is DisplayObject) { 
     630                                clip = Draw.clone(skin[element], false); 
     631                                return clip; 
     632                        } else { 
     633                                return null; 
     634                        } 
    610635                } 
    611636                 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/view/components/CoreComponent.as

    r1847 r2040  
    1313        import flash.geom.Rectangle; 
    1414 
    15         public class CoreComponent extends MovieClip implements IGlobalEventDispatcher,IPlayerComponent { 
     15        public class CoreComponent extends MovieClip implements IGlobalEventDispatcher, IPlayerComponent { 
    1616 
    1717                private var _dispatcher:IGlobalEventDispatcher; 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/view/components/DisplayComponent.as

    r1847 r2040  
    6464                protected var _previousState:String; 
    6565                 
     66                protected var _forced:String = ""; 
     67                 
    6668                public function DisplayComponent(player:IPlayer) { 
    6769                        super(player, "display"); 
     
    348350                } 
    349351                 
     352                protected function get currentState():String { 
     353                        return (_forced ? _forced : (_player ? _player.state : PlayerState.IDLE)); 
     354                } 
    350355                 
    351356                protected function stateHandler(event:PlayerEvent = null):void { 
    352                         if (_previousState != player.state || !(event is PlayerStateEvent)) { 
     357                        if (_previousState != currentState || !(event is PlayerStateEvent)) { 
     358                                _previousState = currentState; 
    353359                                //TODO: Handle mute button in error state 
    354360                                clearRotation(); 
     
    357363                                _bufferStateTimer.delay = (_icon ? 10 : 200); 
    358364                                _playStateTimer.delay = (_icon ? 10 : 10); 
    359                                 switch (player.state) { 
     365                                switch (currentState) { 
    360366                                        case PlayerState.BUFFERING: 
    361367                                                _bufferStateTimer.start(); 
     
    419425                                        navigateToURL(new URLRequest(Strings.cleanLink(link)),_player.config.linktarget); 
    420426                                } 
    421                         } else if (player.state == PlayerState.PLAYING || player.state == PlayerState.BUFFERING) { 
     427                        } else if (currentState == PlayerState.PLAYING || currentState == PlayerState.BUFFERING) { 
    422428                                dispatchEvent(new ViewEvent(ViewEvent.JWPLAYER_VIEW_PAUSE)); 
    423429                        } else { 
     
    463469                } 
    464470                 
     471                public function forceState(forcedState:String):void { 
     472                        switch(forcedState) { 
     473                                case PlayerState.BUFFERING: 
     474                                case PlayerState.PAUSED: 
     475                                case PlayerState.IDLE: 
     476                                case PlayerState.PLAYING: 
     477                                        _forced = forcedState; 
     478                                        stateHandler(); 
     479                                        break; 
     480                                default: 
     481                                        _forced = ""; 
     482                        } 
     483                         
     484                } 
     485                 
     486                public function releaseState():void { 
     487                        _forced = ""; 
     488                        stateHandler(); 
     489                } 
     490                 
    465491                protected override function get displayRect():Rectangle { 
    466492                        return _iconArea ? _iconArea : super.displayRect; 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/view/interfaces/IDisplayComponent.as

    r1838 r2040  
    3939                function setIcon(displayIcon:DisplayObject):void; 
    4040                function setText(displayText:String):void; 
     41                function forceState(forcedState:String):void; 
     42                function releaseState():void; 
    4143        } 
    4244} 
Note: See TracChangeset for help on using the changeset viewer.