Changeset 2047


Ignore:
Timestamp:
01/11/12 19:06:36 (17 months ago)
Author:
pablo
Message:

Completes the InStream API with HTML5 mode support (644)

Location:
branches/fl5_instream
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • branches/fl5_instream/js/bin-debug/jwplayer.js

    r2043 r2047  
    1919var $jw = jwplayer; 
    2020 
    21 jwplayer.version = '5.9.2043'; 
     21jwplayer.version = '5.9.2047'; 
    2222 
    2323// "Shiv" method for older IE browsers; required for parsing media tags 
     
    987987                /** Add an event listener for all events. **/ 
    988988                this.removeGlobalListener = function(listener) { 
    989                         if (!_globallisteners[type]) { 
     989                        if (!listener) { 
    990990                                return; 
    991991                        } 
     
    42364236                var _falseFullscreen = false; 
    42374237                var _normalscreenWidth, _normalscreenHeight; 
    4238                 var _instremArea; 
     4238                var _instremArea, _instreamMode; 
    42394239                 
    42404240                function createWrapper() { 
     
    43184318                 
    43194319                function _stateHandler(evt) { 
    4320                         _css(_box, { 
    4321                                 display: (_model.getMedia() && _model.getMedia().hasChrome() && evt.newstate != jwplayer.api.events.state.IDLE) ? "none" : "block" 
    4322                         }); 
     4320                        if (_instreamMode) { return; } 
     4321                         
     4322                        if (_model.getMedia() && _model.getMedia().hasChrome()) { 
     4323                                _box.style.display = "block"; 
     4324                        } else { 
     4325                                switch (evt.newstate) { 
     4326                                case evt.newstate == jwplayer.api.events.state.PLAYING: 
     4327                                        _box.style.display = "none"; 
     4328                                        break; 
     4329                                default: 
     4330                                        _box.style.display = "block"; 
     4331                                        break; 
     4332                                } 
     4333                        } 
    43234334                } 
    43244335 
     
    43514362                        _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_PLAYER_STATE, _stateHandler); 
    43524363                        _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_MEDIA_LOADED, _loadedHandler); 
    4353                         _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_MEDIA_META, function() { 
     4364                        _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_MEDIA_META, function(evt) { 
    43544365                                _resizeMedia(); 
    43554366                        }); 
     
    45284539                } 
    45294540                 
    4530                 function _resizeMedia() { 
     4541                var _resizeMedia = this.resizeMedia = function() { 
    45314542                        if (!_utils.exists(_model.getMedia())) { 
    45324543                                return; 
     
    45744585                } 
    45754586                 
    4576                 function _getComponentPosition(pluginName) { 
     4587                var _getComponentPosition = this.getComponentPosition = function(pluginName) { 
    45774588                        var plugincss = { 
    45784589                                position: "absolute", 
     
    46994710                        return false; 
    47004711                } 
    4701                 ///             public function setupInstream(_instreamDisplay:DisplayObject, plugin:IPlugin):void { 
    47024712                 
    47034713                this.setupInstream = function(instreamDisplay) { 
     
    47054715                        _box.style.display = "none"; 
    47064716                        _instreamArea.appendChild(instreamDisplay); 
    4707                 } 
    4708                  
    4709                 ///                     public function destroyInstream():void { 
     4717                        _instreamMode = true; 
     4718                } 
     4719                 
    47104720                var _destroyInstream = this.destroyInstream = function() { 
    47114721                        _instreamArea.style.display = "none"; 
     4722                        _instreamArea.innerHTML = ""; 
    47124723                        _box.style.display = "block"; 
    4713                 } 
    4714         }; 
    4715          
    4716          
    4717         //TODO: Enum 
     4724                        _instreamMode = false; 
     4725                        _resize(_model.width, _model.height); 
     4726                } 
     4727        }; 
     4728         
     4729         
    47184730        jwplayer.html5.view.positions = { 
    47194731                TOP: "TOP", 
     
    56055617                                _hide(_elements.muteButton); 
    56065618                                _show(_elements.unmuteButton); 
     5619                                _hide(_elements.volumeSliderProgress); 
    56075620                        } else { 
    56085621                                _show(_elements.muteButton); 
    56095622                                _hide(_elements.unmuteButton); 
     5623                                _show(_elements.volumeSliderProgress); 
    56105624                        } 
    56115625                } 
     
    57475761                        _preplay = false, 
    57485762                        _interruptPlay = false, 
     5763                        _actionOnAttach, 
    57495764                        _queuedEvents = [], 
    57505765                        _ready = false; 
     
    58165831                function _play() { 
    58175832                        try { 
     5833                                _actionOnAttach = _play; 
    58185834                                if (!_preplay) { 
    58195835                                        _preplay = true; 
     
    58225838                                        if (_interruptPlay) { 
    58235839                                                _interruptPlay = false; 
     5840                                                _actionOnAttach = null; 
    58245841                                                return; 
    58255842                                        } 
     
    58385855                        } catch (err) { 
    58395856                                _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_ERROR, err); 
     5857                                _actionOnAttach = null; 
    58405858                        } 
    58415859                        return false; 
     
    59025920                /** Stop playback and loading of the video. **/ 
    59035921                function _stop(clear) { 
     5922                        _actionOnAttach = null; 
    59045923                        if (!_utils.exists(clear)) { 
    59055924                                clear = true; 
     
    60436062                                                break; 
    60446063                                } 
     6064                                _model.volume = volume; 
    60456065                                return true; 
    60466066                        } catch (err) { 
     
    61746194                function _attachMedia() { 
    61756195                        try { 
    6176                                 return _model.getMedia().attachMedia(); 
     6196                                var ret = _model.getMedia().attachMedia(); 
     6197                                if (typeof _actionOnAttach == "function") { 
     6198                                        _actionOnAttach(); 
     6199                                } 
    61776200                        } catch (err) { 
    61786201                                return null; 
     
    61886211                 
    61896212                function _completeHandler() { 
     6213                        _actionOnAttach = _completeHandler;                      
    61906214                        switch (_model.config.repeat.toUpperCase()) { 
    61916215                                case jwplayer.html5.controller.repeatoptions.SINGLE: 
     
    62476271                this.playerReady = _playerReady; 
    62486272                this.detachMedia = _detachMedia;  
    6249                 this.attachMedia = _attachMedia;  
     6273                this.attachMedia = _attachMedia; 
     6274                this.beforePlay = function() {  
     6275                        return _preplay;  
     6276                } 
    62506277        }; 
    62516278})(jwplayer); 
     
    65906617                                return; 
    65916618                        } 
     6619 
    65926620                        _lastState = state; 
    65936621 
     
    66186646                        switch (state) { 
    66196647                                case jwplayer.api.events.state.BUFFERING: 
    6620                                         if (_utils.isMobile()) { 
     6648                                        if (_utils.isIPod()) { 
    66216649                                                _resetPoster(); 
    66226650                                                _hideDisplayIcon(); 
    66236651                                        } else { 
    6624                                                 if (_api.jwGetPlaylist()[_api.jwGetItem()].provider == "sound") { 
     6652                                                if (_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].provider == "sound") { 
    66256653                                                        _showImage(); 
    66266654                                                } 
     
    66356663                                        break; 
    66366664                                case jwplayer.api.events.state.PAUSED: 
    6637                                         if (!_utils.isMobile()) { 
    6638                                                 if (_api.jwGetPlaylist()[_api.jwGetItem()].provider != "sound") { 
     6665                                        if (!_utils.isIPod()) { 
     6666                                                if (_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].provider != "sound") { 
    66396667                                                        _css(_display.display_image, { 
    66406668                                                                background: "transparent no-repeat center center" 
     
    66466674                                        break; 
    66476675                                case jwplayer.api.events.state.IDLE: 
    6648                                         if (_api.jwGetPlaylist()[_api.jwGetItem()] && _api.jwGetPlaylist()[_api.jwGetItem()].image) { 
     6676                                        if (_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()] && _api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].image) { 
    66496677                                                _showImage(); 
    66506678                                        } else { 
     
    66556683                                        break; 
    66566684                                default: 
    6657                                         if (_api.jwGetPlaylist()[_api.jwGetItem()] && _api.jwGetPlaylist()[_api.jwGetItem()].provider == "sound") { 
    6658                                                 if (_utils.isMobile()) { 
     6685                                        if (_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()] && _api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].provider == "sound") { 
     6686                                                if (_utils.isIPod()) { 
    66596687                                                        _resetPoster(); 
    66606688                                                        _showing = false; 
     
    66776705                 
    66786706                function _showImage() { 
    6679                         if (_api.jwGetPlaylist()[_api.jwGetItem()] && _api.jwGetPlaylist()[_api.jwGetItem()].image) { 
     6707                        if (_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()] && _api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].image) { 
    66806708                                _css(_display.display_image, { 
    66816709                                        display: "block" 
    66826710                                }); 
    6683                                 _display.display_image.src = _utils.getAbsolutePath(_api.jwGetPlaylist()[_api.jwGetItem()].image); 
     6711                                _display.display_image.src = _utils.getAbsolutePath(_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].image); 
    66846712                        } 
    66856713                } 
     
    70497077        var _utils = jwplayer.utils; 
    70507078         
    7051         jwplayer.html5.instream = function(item, options, api, model, view, controller) { 
    7052                 var _item = new jwplayer.html5.playlistitem(item), 
    7053                         _api = api, 
    7054                         _options = options, 
    7055                         _model = model, 
    7056                         _view = view, 
    7057                         _controller = controller, 
    7058                         _currentItem = _model.item, 
    7059                         _currentPlaylist = _model.playlist, 
    7060                         _video, _oldsrc, _oldsources, _oldpos, 
    7061                         _self = this, 
    7062                         _provider, _cbar, 
     7079        jwplayer.html5.instream = function(api, model, view, controller) { 
     7080                var _defaultOptions = { 
     7081                        controlbarseekable:"always", 
     7082                        controlbarpausable:true, 
     7083                        controlbarstoppable:true, 
     7084                        playlistclickable:true 
     7085                }; 
     7086                 
     7087                var _item, 
     7088                        _options, 
     7089                        _api=api, _model=model, _view=view, _controller=controller, 
     7090                        _video, _oldsrc, _oldsources, _oldpos, _oldstate, _olditem, 
     7091                        _provider, _cbar, _disp, _instreamMode = false, 
     7092                        _dispatcher, _instreamContainer, 
     7093                        _self = this; 
     7094 
     7095 
     7096                /***************************************** 
     7097                 *****  Public instream API methods  ***** 
     7098                 *****************************************/ 
     7099 
     7100                /** Load an instream item and initialize playback **/ 
     7101                this.load = function(item, options) { 
     7102                        // Update the instream player's model 
     7103                        _copyModel(); 
     7104                        // Sets internal instream mode to true 
     7105                        _instreamMode = true; 
     7106                        // Instream playback options 
     7107                        _options = _utils.extend(_defaultOptions, options); 
     7108                        // Copy the playlist item passed in and make sure it's formatted as a proper playlist item 
     7109                        _item = jwplayer.html5.playlistitem(item); 
     7110                        // Create (or reuse) video media provider.  No checks right now to make sure it's a valid playlist item (i.e. provider="video"). 
     7111                        _setupProvider(); 
     7112                        // Create the container in which the controls will be placed 
     7113                        _instreamContainer = document.createElement("div"); 
     7114                        _instreamContainer.id = _self.id + "_instream_container"; 
     7115                        // Get the video tag, and make sure the original player's provider stops broadcasting events (pseudo-lock...) 
     7116                        _video = _controller.detachMedia(); 
     7117                        // Store this to compare later (in case the main player switches to the next playlist item when we switch out of instream playback mode  
     7118                        _olditem = _model.playlist[_model.item]; 
     7119                        // Keep track of the original player state 
     7120                        _oldstate = _api.jwGetState(); 
     7121                        // If the player's currently playing, pause the video tag 
     7122                        if (_oldstate == jwplayer.api.events.state.BUFFERING || _oldstate == jwplayer.api.events.state.PLAYING) { 
     7123                                _video.pause(); 
     7124                        } 
     7125                         
     7126                        // Copy the video src/sources tags and store the current playback time 
     7127                        _oldsrc = _video.src; 
     7128                        _oldsources = _video.innerHTML; 
     7129                        _oldpos = _video.currentTime; 
     7130                         
     7131                        // Instream display component 
     7132                        _disp = new jwplayer.html5.display(_self, _utils.extend({},_model.plugins.config.display)); 
     7133                        _instreamContainer.appendChild(_disp.getDisplayElement()); 
     7134 
     7135                        // Instream controlbar (if not iOS/Android) 
     7136                        if (!_utils.isMobile()) { 
     7137                                _cbar = new jwplayer.html5.controlbar(_self, _utils.extend({},_model.plugins.config.controlbar, {})); 
     7138                                _instreamContainer.appendChild(_cbar.getDisplayElement()); 
     7139                        } 
     7140 
     7141                        // Show the instream layer 
     7142                        _view.setupInstream(_instreamContainer); 
     7143                        // Resize the instream components to the proper size 
     7144                        _resize(_model.plugins.config.display.width, _model.plugins.config.display.height); 
     7145                        // Load the instream item and begin playback 
     7146                        _provider.load(_item); 
     7147                } 
     7148                         
     7149                /** Stop the instream playback and revert the main player back to its original state **/ 
     7150                this.jwInstreamDestroy = function(complete) { 
     7151                        if (!_instreamMode) return; 
     7152                        // We're not in instream mode anymore. 
     7153                        _instreamMode = false; 
     7154                        // Load the original item into our provider, which sets up the regular player's video tag 
     7155                        _provider.load(_olditem, false); 
     7156                        // We don't want the position interval to be running anymore 
     7157                        _provider.stop(false); 
     7158                        // We don't want the instream provider to be attached to the video tag anymore 
     7159                        _provider.detachMedia(); 
     7160                        // Return the view to its normal state 
     7161                        _view.destroyInstream(); 
     7162                        // Let listeners know the instream player has been destroyed, and why 
     7163                        _sendEvent(jwplayer.api.events.JWPLAYER_INSTREAM_DESTROYED, {reason:(complete ? "complete":"destroyed")}, true); 
     7164                        // Re-attach the controller 
     7165                        _controller.attachMedia(); 
     7166                        if (_oldstate == jwplayer.api.events.state.BUFFERING || _oldstate == jwplayer.api.events.state.PLAYING) { 
     7167                                // Model was already correct; just resume playback 
     7168                                _video.play(); 
     7169                                if (_model.playlist[_model.item] == _olditem) { 
     7170                                        // We need to seek using the player's real provider, since the seek may have to be delayed 
     7171                                        _model.getMedia().seek(_oldpos); 
     7172                                } 
     7173                        } 
     7174                        return; 
     7175                }; 
     7176                 
     7177                /** Forward any calls to add and remove events directly to our event dispatcher **/ 
     7178                this.jwInstreamAddEventListener = function(type, listener) { 
     7179                        _dispatcher.addEventListener(type, listener); 
     7180                }  
     7181                this.jwInstreamRemoveEventListener = function(type, listener) { 
     7182                        _dispatcher.removeEventListener(type, listener); 
     7183                } 
     7184 
     7185                /** Start instream playback **/ 
     7186                this.jwInstreamPlay = function() { 
     7187                        if (!_instreamMode) return; 
     7188                        _provider.play(true); 
     7189                } 
     7190 
     7191                /** Pause instream playback **/ 
     7192                this.jwInstreamPause = function() { 
     7193                        if (!_instreamMode) return; 
     7194                        _provider.pause(true); 
     7195                } 
     7196                 
     7197                /** Seek to a point in instream media **/ 
     7198                this.jwInstreamSeek = function(position) { 
     7199                        if (!_instreamMode) return; 
     7200                        _provider.seek(position); 
     7201                } 
     7202                 
     7203                /** Get the current instream state **/ 
     7204                this.jwInstreamGetState = function() { 
     7205                        if (!_instreamMode) return undefined; 
     7206                        return _fakemodel.state; 
     7207                } 
     7208 
     7209                /** Get the current instream playback position **/ 
     7210                this.jwInstreamGetPosition = function() { 
     7211                        if (!_instreamMode) return undefined; 
     7212                        return _fakemodel.position; 
     7213                } 
     7214 
     7215                /** Get the current instream media duration **/ 
     7216                this.jwInstreamGetDuration = function() { 
     7217                        if (!_instreamMode) return undefined; 
     7218                        return _fakemodel.duration; 
     7219                } 
     7220                 
     7221                this.playlistClickable = function() { 
     7222                        return (!_instreamMode || _options.playlistclickable.toString().toLowerCase()=="true"); 
     7223                } 
     7224                 
     7225 
     7226                /***************************** 
     7227                 ****** Private methods ******  
     7228                 *****************************/ 
     7229 
     7230                function _init() { 
     7231                        // Initialize the instream player's model copied from main player's model 
     7232                        _fakemodel = new jwplayer.html5.model(this, _model.getMedia() ? _model.getMedia().getDisplayElement() : _model.container, _model); 
     7233                        // Create new event dispatcher 
    70637234                        _dispatcher = new jwplayer.html5.eventdispatcher(); 
    7064                  
    7065  
    7066                 function _init() { 
    7067                         var _thing = document.createElement("div"); 
    7068                         _thing.id = _self.id; 
    7069  
    7070                         _controller.pause(); 
    7071                         _video = _controller.detachMedia(); 
    7072 //                      _video.style.zIndex = 10; 
    7073  
    7074                          
    7075                         _oldsrc = _video.src; 
    7076                         _oldsources = _video.getElementsByTagName("source"); 
    7077                         _oldpos = _video.currentPosition; 
    7078                          
    7079                         _view.setupInstream(_thing); 
    7080  
    7081                         _setupProvider(); 
    7082                          
    7083                         _cbar = new jwplayer.html5.controlbar(_self, _utils.extend({},_model.plugins.config.controlbar, {position:"OVER"})); 
    7084                          
    7085                         _thing.appendChild(_cbar.getDisplayElement()); 
    7086                          
    7087                          
    7088                         _resize(_api.jwGetWidth(), _api.jwGetHeight()); 
    7089  
    7090                         _provider.load(_item); 
    7091                          
    7092                         return; 
    7093                 }; 
     7235                        // Listen for player resize events 
     7236                        _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_RESIZE, function(evt) { 
     7237                                _resize(evt.width, evt.height); 
     7238                        }); 
     7239                        _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_FULLSCREEN, function(evt) { 
     7240                                _resize(evt.width, evt.height); 
     7241                        }); 
     7242                } 
     7243 
     7244                function _copyModel() { 
     7245                        _fakemodel.mute = _model.mute; 
     7246                        _fakemodel.volume = _model.volume; 
     7247                } 
    70947248                 
    70957249                function _setupProvider() { 
    7096                         _provider = new jwplayer.html5.mediavideo(_model, _model.getMedia() ? _model.getMedia().getDisplayElement() : _model.container); 
    7097                         _provider.addGlobalListener( 
    7098                                 function(evt) { 
    7099                                         _dispatcher.sendEvent(evt.type, evt); 
    7100                                 } 
    7101                         ); 
    7102                         _provider.addEventListener(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE, function(evt) { 
    7103                                 _self.jwInstreamDestroy(); 
    7104                         }); 
    7105                 } 
    7106                  
     7250                        if (!_provider) { 
     7251                                _provider = new jwplayer.html5.mediavideo(_fakemodel, _model.getMedia() ? _model.getMedia().getDisplayElement() : _model.container); 
     7252                                _provider.addGlobalListener(_forward); 
     7253                                _provider.addEventListener(jwplayer.api.events.JWPLAYER_MEDIA_META, _metaHandler); 
     7254                                _provider.addEventListener(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE, _completeHandler); 
     7255                        } 
     7256                        _provider.attachMedia(); 
     7257                } 
     7258                 
     7259                /** Forward provider events to listeners **/             
     7260                function _forward(evt) { 
     7261                        if (_instreamMode) { 
     7262                                _sendEvent(evt.type, evt); 
     7263                        } 
     7264                } 
     7265                 
     7266                /** Handle the JWPLAYER_MEDIA_COMPLETE event **/                 
     7267                function _completeHandler(evt) { 
     7268                        if (_instreamMode) { 
     7269                                setTimeout(function() { 
     7270                                        _self.jwInstreamDestroy(true); 
     7271                                }, 10); 
     7272                        } 
     7273                } 
     7274                 
     7275                /** Handle the JWPLAYER_MEDIA_META event **/             
     7276                function _metaHandler(evt) { 
     7277                        // If we're getting video dimension metadata from the provider, allow the view to resize the media 
     7278                        if (evt.metadata.width && evt.metadata.height) { 
     7279                                _view.resizeMedia(); 
     7280                        } 
     7281                } 
     7282                 
     7283                function _sendEvent(type, data, forceSend) { 
     7284                        if (_instreamMode || forceSend) { 
     7285                                _dispatcher.sendEvent(type, data); 
     7286                        } 
     7287                } 
     7288                 
     7289                // Resize handler; resize the components. 
    71077290                function _resize(width, height) { 
    7108                         _css(_cbar.getDisplayElement(), { 
    7109                                 position: "absolute", 
    7110                                 width: width, 
    7111                                 height: height, 
    7112                                 zIndex: 1000 
    7113                         }); 
    7114                         _cbar.resize(width, height); 
    7115                 } 
    7116                  
    7117                 this.jwInstreamAddEventListener = _dispatcher.addEventListener;  
    7118                 this.jwInstreamRemoveEventListener = _dispatcher.removeEventListener;  
    7119                  
    7120                 this.jwInstreamPlay = function() { 
    7121                 } 
    7122  
    7123                 this.jwInstreamPause = function() { 
    7124                 } 
    7125                  
    7126                 this.jwInstreamSeek = function(position) { 
    7127                 } 
    7128  
    7129                  
    7130                 this.jwInstreamGetState = function() { 
    7131                 } 
    7132  
    7133                 this.jwInstreamGetPosition = function() { 
    7134                 } 
    7135  
    7136                 this.jwInstreamGetDuration = function() { 
    7137                 } 
    7138  
    7139                 this.jwInstreamDestroy = function() { 
    7140                         _video.pause(); 
    7141                         _video.src = _oldsrc; 
    7142                         for (var i=0; i < _oldsources.length; i++) { 
    7143                                 _video.appendChild(_oldsources[i]); 
    7144                         } 
    7145                         _video.currentPosition = _oldpos; 
    7146                         _video.load(); 
    7147                         _view.destroyInstream(); 
    7148                          
    7149                         _controller.attachMedia(); 
    7150 //                      _model.getMedia().load(_currentPlaylist[_currentItem]); 
    7151 //                      _video.pause(); 
    7152                         //_utils.setOuterHTML(_video, _videoHTML); 
    7153                 } 
    7154                  
    7155                  
    7156                 /** Duplicate main html5 api **/ 
    7157                 this.skin = _api.skin; 
    7158                  
    7159                 this.jwPlay = function(state) {}; 
    7160                 this.jwPause = function(state) {}; 
    7161                 this.jwSeek = function(position) {}; 
    7162                 this.jwStop = function() {}; 
    7163                 this.jwGetItem = function() {}; 
     7291                        if (_cbar) { 
     7292                                var originalBar = _view.getComponentPosition('controlbar'); 
     7293                                _css(_cbar.getDisplayElement(), _utils.extend({}, originalBar, { 
     7294                                        position: "absolute", 
     7295                                        zIndex: 1001 
     7296                                })); 
     7297                                _cbar.resize(originalBar.width, originalBar.height); 
     7298                        } 
     7299                        if (_disp) { 
     7300                                var originalDisp = _view.getComponentPosition('display'); 
     7301                                _css(_disp.getDisplayElement(), _utils.extend({}, originalDisp, { 
     7302                                        position: "absolute", 
     7303                                        zIndex: 1000 
     7304                                })); 
     7305                                _disp.resize(originalDisp.width, originalDisp.height); 
     7306                        } 
     7307                        if (_view) { 
     7308                                _view.resizeMedia(); 
     7309                        } 
     7310                } 
     7311                 
     7312                 
     7313                /************************************** 
     7314                 *****  Duplicate main html5 api  ***** 
     7315                 **************************************/ 
     7316                 
     7317                this.jwPlay = function(state) { 
     7318                        if (_options.controlbarpausable.toString().toLowerCase()=="true") { 
     7319                                this.jwInstreamPlay(); 
     7320                        } 
     7321                }; 
     7322                 
     7323                this.jwPause = function(state) { 
     7324                        if (_options.controlbarpausable.toString().toLowerCase()=="true") { 
     7325                                this.jwInstreamPause(); 
     7326                        } 
     7327                }; 
     7328 
     7329                this.jwStop = function() { 
     7330                        if (_options.controlbarstoppable.toString().toLowerCase()=="true") { 
     7331                                this.jwInstreamDestroy(); 
     7332                        } 
     7333                }; 
     7334 
     7335                this.jwSeek = function(position) { 
     7336                        switch(_options.controlbarseekable.toLowerCase()) { 
     7337                        case "always": 
     7338                                this.jwInstreamSeek(position); 
     7339                                break; 
     7340                        case "backwards": 
     7341                                if (_fakemodel.position > position) { 
     7342                                        this.jwInstreamSeek(position); 
     7343                                } 
     7344                                break; 
     7345                        } 
     7346                }; 
     7347                 
    71647348                this.jwGetPosition = function() {}; 
    71657349                this.jwGetDuration = function() {}; 
    7166  
    71677350                this.jwGetWidth = _api.jwGetWidth; 
    71687351                this.jwGetHeight = _api.jwGetHeight; 
    7169  
    71707352                this.jwGetFullscreen = _api.jwGetFullscreen; 
    71717353                this.jwSetFullscreen = _api.jwSetFullscreen; 
    7172  
    7173                 this.jwGetVolume = _api.jwGetVolume; 
    7174                 this.jwSetVolume = _api.jwSetVolume; 
    7175  
    7176                 this.jwGetMute = _api.jwGetMute; 
    7177                 this.jwSetMute = _api.setMute; 
    7178  
    7179                 this.jwGetState = function() {}; 
    7180                  
    7181                 this.jwGetPlaylist = function() { 
    7182                         return [_item]; 
    7183                 }; 
    7184                 this.jwGetPlaylistIndex = function() { 
    7185                         return 0; 
    7186                 }; 
    7187                  
    7188                 this.jwAddEventListener = function(type, handler) { 
    7189                         _dispatcher.addEventListener(type, handler); 
    7190                 } 
    7191                 this.jwRemoveEventListener = _dispatcher.removeEventListener; 
    7192                  
     7354                this.jwGetVolume = function() { return _model.volume; }; 
     7355                this.jwSetVolume = function(vol) { 
     7356                        _provider.volume(vol); 
     7357                        _api.jwSetVolume(vol); 
     7358                } 
     7359                this.jwGetMute = function() { return _model.mute; }; 
     7360                this.jwSetMute = function(state) { 
     7361                        _provider.mute(state); 
     7362                        _api.jwSetMute(state); 
     7363                } 
     7364                this.jwGetState = function() { return _fakemodel.state; }; 
     7365                this.jwGetPlaylist = function() { return [_item]; }; 
     7366                this.jwGetPlaylistIndex = function() { return 0; }; 
     7367                this.jwGetStretching = function() { return _model.config.stretching; }; 
     7368                this.jwAddEventListener = function(type, handler) { _dispatcher.addEventListener(type, handler); }; 
     7369                this.jwRemoveEventListener = function(type, handler) { _dispatcher.removeEventListener(type, handler); }; 
     7370 
     7371                this.skin = _api.skin; 
    71937372                this.id = _api.id; 
    7194                  
     7373 
    71957374                _init(); 
    7196                  
    71977375                return this; 
    71987376        }; 
     
    73957573        var _utils = jwplayer.utils; 
    73967574        var _isMobile = _utils.isMobile(); 
     7575         
     7576        var _allvideos = {}; 
    73977577         
    73987578        jwplayer.html5.mediavideo = function(model, container) { 
     
    74367616                        _currentItem, 
    74377617                        _interval, 
     7618                        _delayedSeek,  
    74387619                        _emptied = false, 
    74397620                        _attached = false, 
     
    74877668                                _video.src = item.file; 
    74887669                        } 
     7670                        _video.style.display = "block"; 
     7671                        _video.volume = _model.volume / 100; 
     7672                        _video.muted = _model.mute; 
    74897673                        if (_isMobile) { 
    7490                                 if (item.image) { 
    7491                                         _video.poster = item.image; 
    7492                                 } 
    7493                                 _video.style.display = "block"; 
    7494                                 setTimeout(function() { 
    7495                                         _video.setAttribute("controls", "controls"); 
    7496                                 }, 100); 
     7674                                _setControls(); 
    74977675                        } 
    74987676                         
     
    75037681                                item.start = 0; 
    75047682                        } 
    7505                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_LOADED); 
     7683                        _delayedSeek = (item.start > 0) ? item.start : -1; 
     7684                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_LOADED); 
    75067685                        if((!_isMobile && item.levels.length == 1) || !_emptied) { 
    75077686                                _video.load(); 
     
    75107689                        if (play) { 
    75117690                                _setState(jwplayer.api.events.state.BUFFERING); 
    7512                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER, { 
     7691                                _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER, { 
    75137692                                        bufferPercent: 0 
    75147693                                }); 
     
    75237702                        if (!_attached) return; 
    75247703                         
    7525                         if (_state != jwplayer.api.events.state.PLAYING) { 
    7526                                 _startInterval(); 
    7527                                 if (_bufferFull) { 
    7528                                         _setState(jwplayer.api.events.state.PLAYING); 
    7529                                 } else { 
    7530                                         _setState(jwplayer.api.events.state.BUFFERING); 
    7531                                 } 
    7532                                 _video.play(); 
    7533                         } 
     7704                        _startInterval(); 
     7705                        if (_bufferFull) { 
     7706                                _setState(jwplayer.api.events.state.PLAYING); 
     7707                        } else { 
     7708                                _setState(jwplayer.api.events.state.BUFFERING); 
     7709                        } 
     7710                        _video.play(); 
    75347711                } 
    75357712                 
     
    75507727                this.seek = function(position) { 
    75517728                        if (!_attached) return; 
    7552                          
    7553                         if (!(_model.duration <= 0 || isNaN(_model.duration)) && 
    7554                                 !(_model.position <= 0 || isNaN(_model.position))) { 
    7555                                         _video.currentTime = position; 
    7556                                         _video.play(); 
     7729                        if (!_start && _video.readyState > 0) { 
     7730                                if (!(_model.duration <= 0 || isNaN(_model.duration)) && 
     7731                                                !(_model.position <= 0 || isNaN(_model.position))) { 
     7732                                                _video.currentTime = position; 
     7733                                                _video.play(); 
     7734                                } 
     7735                        } else { 
     7736                                _delayedSeek = position; 
    75577737                        } 
    75587738                } 
     
    75827762                                        _video.removeAttribute("src"); 
    75837763                                } 
    7584                                 _video.removeAttribute("controls"); 
    7585                                 _video.removeAttribute("poster"); 
     7764                                _hideControls(); 
    75867765                                _utils.empty(_video); 
    75877766                                _video.load(); 
     
    76077786                /** Resize the player. **/ 
    76087787                this.resize = function(width, height) { 
    7609 //                      _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_RESIZE, { 
     7788//                      _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_RESIZE, { 
    76107789//                              fullscreen: _model.fullscreen, 
    76117790//                              width: width, 
     
    76187797                        if (!_isMobile) { 
    76197798                                _video.volume = position / 100; 
    7620                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_VOLUME, { 
     7799                                _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_VOLUME, { 
    76217800                                        volume: (position / 100) 
    76227801                                }); 
     
    76297808                        if (!_isMobile) { 
    76307809                                _video.muted = state; 
    7631                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, { 
     7810                                _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, { 
    76327811                                        mute: state 
    76337812                                }); 
     
    76717850                function _handleMediaEvent(type, handler) { 
    76727851                        return function(evt) { 
    7673                                 if (_attached && _utils.exists(evt.target.parentNode)) { 
     7852                                if (_utils.exists(evt.target.parentNode)) { 
    76747853                                        handler(evt); 
    76757854                                } 
     
    76797858                /** Initializes the HTML5 video and audio media provider **/ 
    76807859                function _init() { 
    7681                         if (!_video) { 
    7682                                 if (_container.tagName.toLowerCase() == "video") { 
    7683                                         _video = _container; 
    7684                                 } else { 
    7685                                         _video = document.createElement("video"); 
    7686                                 } 
    7687                         } 
    76887860                        _state = jwplayer.api.events.state.IDLE; 
    76897861  
    7690                         for (var event in _events) { 
    7691                                 _video.addEventListener(event, _handleMediaEvent(event, _events[event]), true); 
    7692                         } 
    76937862                        _attached = true; 
     7863                         
     7864                        _video = _getVideoElement(); 
    76947865 
    76957866                        _video.setAttribute("x-webkit-airplay", "allow");  
     
    77027873                                _video.id = _container.id; 
    77037874                        } 
    7704                          
    7705                         _video.volume = _model.volume / 100; 
     7875                } 
     7876                 
     7877                function _getVideoElement() { 
     7878                        var vid; 
     7879                        if (!_allvideos[_model.id]) { 
     7880                                if (_container.tagName.toLowerCase() == "video") { 
     7881                                        vid = _container; 
     7882                                } else { 
     7883                                        vid = document.createElement("video"); 
     7884                                } 
     7885                                for (var event in _events) { 
     7886                                        vid.addEventListener(event, _handleMediaEvent(event, _events[event]), true); 
     7887                                } 
     7888                                _allvideos[_model.id] = vid; 
     7889                        } 
     7890                        return _allvideos[_model.id]; 
    77067891                } 
    77077892                 
     
    77137898                        } 
    77147899 
     7900                        if (_isMobile) { 
     7901                                switch (newstate) { 
     7902                                case jwplayer.api.events.state.PLAYING: 
     7903                                        _setControls(); 
     7904                                        break; 
     7905                                default: 
     7906                                        _hideControls(); 
     7907                                        break; 
     7908                                } 
     7909                        } 
     7910                         
    77157911                        if (_state != newstate) { 
    77167912                                var oldstate = _state; 
    77177913                                _model.state = _state = newstate; 
    7718                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_PLAYER_STATE, { 
     7914                                _sendEvent(jwplayer.api.events.JWPLAYER_PLAYER_STATE, { 
    77197915                                        oldstate: oldstate, 
    77207916                                        newstate: newstate 
     
    77317927                function _volumeHandler(event) { 
    77327928                        var newVol = Math.round(_video.volume * 100); 
    7733                         if (newVol != _model.volume) { 
    7734                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_VOLUME, { 
    7735                                         volume: newVol 
    7736                                 }); 
    7737                         } 
    7738                         if (_video.muted != _model.mute) { 
    7739                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, { 
    7740                                         mute: _video.muted 
    7741                                 }); 
    7742                         } 
     7929                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_VOLUME, { 
     7930                                volume: newVol 
     7931                        }, true); 
     7932                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, { 
     7933                                mute: _video.muted 
     7934                        }, true); 
    77437935                } 
    77447936 
    77457937                /** Update the player progress **/ 
    77467938                function _progressHandler(event) { 
     7939                        if (!_attached) return; 
     7940 
    77477941                        var bufferPercent; 
    77487942                        if (_utils.exists(event) && event.lengthComputable && event.total) { 
     
    77567950                         
    77577951                        if (_bufferFull === false && _state == jwplayer.api.events.state.BUFFERING) { 
    7758                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER_FULL); 
     7952                                _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER_FULL); 
    77597953                                _bufferFull = true; 
    77607954                        } 
     
    77677961                                if (_utils.exists(bufferPercent) && (bufferPercent > _model.buffer)) { 
    77687962                                        _model.buffer = Math.round(bufferPercent); 
    7769                                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER, { 
     7963                                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER, { 
    77707964                                                bufferPercent: Math.round(bufferPercent) 
    77717965                                        }); 
     
    77777971                /** Update the player's position **/ 
    77787972                function _positionHandler(event) { 
     7973                        if (!_attached) return; 
     7974 
    77797975                        if (_utils.exists(event) && _utils.exists(event.target)) { 
    7780                                 if (!isNaN(event.target.duration) && (isNaN(_model.duration) || _model.duration < 1)) { 
    7781                                         if (event.target.duration == Infinity) { 
    7782                                                 _model.duration = 0; 
    7783                                         } else { 
    7784                                                 _model.duration = Math.round(event.target.duration * 10) / 10; 
     7976                                if (_userDuration > 0) { 
     7977                                        if (!isNaN(event.target.duration) && (isNaN(_model.duration) || _model.duration < 1)) { 
     7978                                                if (event.target.duration == Infinity) { 
     7979                                                        _model.duration = 0; 
     7980                                                } else { 
     7981                                                        _model.duration = Math.round(event.target.duration * 10) / 10; 
     7982                                                } 
    77857983                                        } 
    77867984                                } 
    77877985                                if (!_start && _video.readyState > 0) { 
    7788                                         _video.style.display = "block"; 
    77897986                                        _setState(jwplayer.api.events.state.PLAYING); 
    77907987                                } 
    77917988                                 
    77927989                                if (_state == jwplayer.api.events.state.PLAYING) { 
    7793                                         if (!_start && _video.readyState > 0) { 
     7990                                        if (_video.readyState > 0 && (_delayedSeek > -1 || !_start)) { 
    77947991                                                _start = true; 
    77957992                                                try { 
    7796                                                         if (_video.currentTime < _currentItem.start) { 
    7797                                                                 _video.currentTime = _currentItem.start; 
     7993                                                        if (_video.currentTime != _delayedSeek && _delayedSeek > -1) { 
     7994                                                                _video.currentTime = _delayedSeek; 
     7995                                                                _delayedSeek = -1; 
    77987996                                                        } 
    77997997                                                } catch (err) {} 
     
    78028000                                        } 
    78038001                                        _model.position = _model.duration > 0 ? (Math.round(event.target.currentTime * 10) / 10) : 0; 
    7804                                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_TIME, { 
     8002                                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_TIME, { 
    78058003                                                position: _model.position, 
    78068004                                                duration: _model.duration 
     
    78198017 
    78208018                function _stateHandler(event) { 
     8019                        if (!_attached) return; 
     8020 
    78218021                        if (_states[event.type]) { 
    78228022                                if (event.type == "ended") { 
     
    78298029 
    78308030                function _metaHandler(event) { 
     8031                        if (!_attached) return; 
    78318032                        var newDuration = Math.round(event.target.duration * 10) / 10; 
    78328033                        var meta = { 
     
    78408041                                } 
    78418042                        } 
    7842                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_META, { 
     8043                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_META, { 
    78438044                                metadata: meta 
    78448045                        }); 
     
    78468047 
    78478048                function _errorHandler(event) { 
     8049                        if (!_attached) return; 
     8050 
    78488051                        if (_state == jwplayer.api.events.state.IDLE) { 
    78498052                                return; 
     
    78848087                        message += _joinFiles(); 
    78858088                        _error = true; 
    7886                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_ERROR, { 
     8089                        _sendEvent(jwplayer.api.events.JWPLAYER_ERROR, { 
    78878090                                message: message 
    78888091                        }); 
     
    79188121                 
    79198122                function _complete() { 
    7920                         if (_state != jwplayer.api.events.state.IDLE) { 
     8123                        if (_state == jwplayer.api.events.state.PLAYING) { 
    79218124                                _stop(false); 
    7922                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE); 
     8125                                setTimeout(function() { 
     8126                                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE); 
     8127                                }, 10); 
    79238128                        } 
    79248129                } 
     
    79288133                                if (_model.fullscreen && !_video.webkitDisplayingFullscreen) { 
    79298134                                        //_model.fullscreen = _video.webkitDisplayingFullscreen; 
    7930                                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_FULLSCREEN, { 
     8135                                        _sendEvent(jwplayer.api.events.JWPLAYER_FULLSCREEN, { 
    79318136                                                fullscreen: false 
    7932                                         }); 
     8137                                        },true); 
    79338138                                } 
    79348139                        } 
     
    79508155                                                levels.unshift(mp4); 
    79518156                                        } 
     8157                                } 
     8158                        } 
     8159                } 
     8160                 
     8161                function _setControls() { 
     8162                        if (_currentItem.image) { 
     8163                                _video.poster = _currentItem.image; 
     8164                        } 
     8165                        setTimeout(function() { 
     8166                                _video.setAttribute("controls", "controls"); 
     8167                        }, 100); 
     8168                } 
     8169                 
     8170                function _hideControls() { 
     8171                        _video.removeAttribute("controls"); 
     8172                        _video.removeAttribute("poster"); 
     8173                } 
     8174                 
     8175                function _sendEvent(type, obj, alwaysSend) { 
     8176                        if (_attached || alwaysSend) { 
     8177                                if (obj) { 
     8178                                        _eventDispatcher.sendEvent(type, obj); 
     8179                                } else { 
     8180                                        _eventDispatcher.sendEvent(type); 
    79528181                                } 
    79538182                        } 
     
    93799608                _api.jwStop = _controller.stop; 
    93809609                _api.jwSeek = _controller.seek; 
    9381                 _api.jwPlaylistItem = _controller.item; 
     9610                _api.jwPlaylistItem = function(item) { 
     9611                        if (_instreamPlayer) { 
     9612                                if (_instreamPlayer.playlistClickable()) { 
     9613                                        _instreamPlayer.jwInstreamDestroy(); 
     9614                                        return _controller.item(item); 
     9615                                } 
     9616                        } else { 
     9617                                return _controller.item(item); 
     9618                        } 
     9619                } 
    93829620                _api.jwPlaylistNext = _controller.next; 
    93839621                _api.jwPlaylistPrev = _controller.prev; 
     
    94029640                } 
    94039641                 
    9404                 _api.jwGetItem = _statevarFactory('item'); 
     9642                _api.jwGetPlaylistIndex = _statevarFactory('item'); 
    94059643                _api.jwGetPosition = _statevarFactory('position'); 
    94069644                _api.jwGetDuration = _statevarFactory('duration'); 
     
    94259663                        return _model.playlist; 
    94269664                }; 
    9427                 _api.jwGetPlaylistIndex = _api.jwGetItem; 
    94289665                 
    94299666                _api.jwAddEventListener = _controller.addEventListener; 
     
    94499686                //InStream API 
    94509687                _api.jwLoadInstream = function(item, options) { 
    9451                         _instreamPlayer = new jwplayer.html5.instream(item, options, _api, _model, _view, _controller); 
     9688                        if (!_instreamPlayer) { 
     9689                                _instreamPlayer = new jwplayer.html5.instream(_api, _model, _view, _controller); 
     9690                        } 
     9691                        setTimeout(function() { 
     9692                                _instreamPlayer.load(item, options); 
     9693                        }, 10); 
    94529694                } 
    94539695                _api.jwInstreamDestroy = function() { 
    94549696                        if (_instreamPlayer) { 
    94559697                                _instreamPlayer.jwInstreamDestroy(); 
    9456                                 _instreamPlayer = null; 
    94579698                        } 
    94589699                } 
  • branches/fl5_instream/js/src/events/jwplayer.events.eventdispatcher.js

    r1858 r2047  
    7676                /** Add an event listener for all events. **/ 
    7777                this.removeGlobalListener = function(listener) { 
    78                         if (!_globallisteners[type]) { 
     78                        if (!listener) { 
    7979                                return; 
    8080                        } 
  • branches/fl5_instream/js/src/html5/jwplayer.html5.api.js

    r2043 r2047  
    5151                _api.jwStop = _controller.stop; 
    5252                _api.jwSeek = _controller.seek; 
    53                 _api.jwPlaylistItem = _controller.item; 
     53                _api.jwPlaylistItem = function(item) { 
     54                        if (_instreamPlayer) { 
     55                                if (_instreamPlayer.playlistClickable()) { 
     56                                        _instreamPlayer.jwInstreamDestroy(); 
     57                                        return _controller.item(item); 
     58                                } 
     59                        } else { 
     60                                return _controller.item(item); 
     61                        } 
     62                } 
    5463                _api.jwPlaylistNext = _controller.next; 
    5564                _api.jwPlaylistPrev = _controller.prev; 
     
    7483                } 
    7584                 
    76                 _api.jwGetItem = _statevarFactory('item'); 
     85                _api.jwGetPlaylistIndex = _statevarFactory('item'); 
    7786                _api.jwGetPosition = _statevarFactory('position'); 
    7887                _api.jwGetDuration = _statevarFactory('duration'); 
     
    97106                        return _model.playlist; 
    98107                }; 
    99                 _api.jwGetPlaylistIndex = _api.jwGetItem; 
    100108                 
    101109                _api.jwAddEventListener = _controller.addEventListener; 
     
    121129                //InStream API 
    122130                _api.jwLoadInstream = function(item, options) { 
    123                         _instreamPlayer = new jwplayer.html5.instream(item, options, _api, _model, _view, _controller); 
     131                        if (!_instreamPlayer) { 
     132                                _instreamPlayer = new jwplayer.html5.instream(_api, _model, _view, _controller); 
     133                        } 
     134                        setTimeout(function() { 
     135                                _instreamPlayer.load(item, options); 
     136                        }, 10); 
    124137                } 
    125138                _api.jwInstreamDestroy = function() { 
    126139                        if (_instreamPlayer) { 
    127140                                _instreamPlayer.jwInstreamDestroy(); 
    128                                 _instreamPlayer = null; 
    129141                        } 
    130142                } 
  • branches/fl5_instream/js/src/html5/jwplayer.html5.controlbar.js

    r2030 r2047  
    879879                                _hide(_elements.muteButton); 
    880880                                _show(_elements.unmuteButton); 
     881                                _hide(_elements.volumeSliderProgress); 
    881882                        } else { 
    882883                                _show(_elements.muteButton); 
    883884                                _hide(_elements.unmuteButton); 
     885                                _show(_elements.volumeSliderProgress); 
    884886                        } 
    885887                } 
  • branches/fl5_instream/js/src/html5/jwplayer.html5.controller.js

    r2032 r2047  
    1919                        _preplay = false, 
    2020                        _interruptPlay = false, 
     21                        _actionOnAttach, 
    2122                        _queuedEvents = [], 
    2223                        _ready = false; 
     
    8889                function _play() { 
    8990                        try { 
     91                                _actionOnAttach = _play; 
    9092                                if (!_preplay) { 
    9193                                        _preplay = true; 
     
    9496                                        if (_interruptPlay) { 
    9597                                                _interruptPlay = false; 
     98                                                _actionOnAttach = null; 
    9699                                                return; 
    97100                                        } 
     
    110113                        } catch (err) { 
    111114                                _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_ERROR, err); 
     115                                _actionOnAttach = null; 
    112116                        } 
    113117                        return false; 
     
    174178                /** Stop playback and loading of the video. **/ 
    175179                function _stop(clear) { 
     180                        _actionOnAttach = null; 
    176181                        if (!_utils.exists(clear)) { 
    177182                                clear = true; 
     
    315320                                                break; 
    316321                                } 
     322                                _model.volume = volume; 
    317323                                return true; 
    318324                        } catch (err) { 
     
    446452                function _attachMedia() { 
    447453                        try { 
    448                                 return _model.getMedia().attachMedia(); 
     454                                var ret = _model.getMedia().attachMedia(); 
     455                                if (typeof _actionOnAttach == "function") { 
     456                                        _actionOnAttach(); 
     457                                } 
    449458                        } catch (err) { 
    450459                                return null; 
     
    460469                 
    461470                function _completeHandler() { 
     471                        _actionOnAttach = _completeHandler;                      
    462472                        switch (_model.config.repeat.toUpperCase()) { 
    463473                                case jwplayer.html5.controller.repeatoptions.SINGLE: 
     
    519529                this.playerReady = _playerReady; 
    520530                this.detachMedia = _detachMedia;  
    521                 this.attachMedia = _attachMedia;  
     531                this.attachMedia = _attachMedia; 
     532                this.beforePlay = function() {  
     533                        return _preplay;  
     534                } 
    522535        }; 
    523536})(jwplayer); 
  • branches/fl5_instream/js/src/html5/jwplayer.html5.display.js

    r2021 r2047  
    314314                                return; 
    315315                        } 
     316 
    316317                        _lastState = state; 
    317318 
     
    342343                        switch (state) { 
    343344                                case jwplayer.api.events.state.BUFFERING: 
    344                                         if (_utils.isMobile()) { 
     345                                        if (_utils.isIPod()) { 
    345346                                                _resetPoster(); 
    346347                                                _hideDisplayIcon(); 
    347348                                        } else { 
    348                                                 if (_api.jwGetPlaylist()[_api.jwGetItem()].provider == "sound") { 
     349                                                if (_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].provider == "sound") { 
    349350                                                        _showImage(); 
    350351                                                } 
     
    359360                                        break; 
    360361                                case jwplayer.api.events.state.PAUSED: 
    361                                         if (!_utils.isMobile()) { 
    362                                                 if (_api.jwGetPlaylist()[_api.jwGetItem()].provider != "sound") { 
     362                                        if (!_utils.isIPod()) { 
     363                                                if (_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].provider != "sound") { 
    363364                                                        _css(_display.display_image, { 
    364365                                                                background: "transparent no-repeat center center" 
     
    370371                                        break; 
    371372                                case jwplayer.api.events.state.IDLE: 
    372                                         if (_api.jwGetPlaylist()[_api.jwGetItem()] && _api.jwGetPlaylist()[_api.jwGetItem()].image) { 
     373                                        if (_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()] && _api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].image) { 
    373374                                                _showImage(); 
    374375                                        } else { 
     
    379380                                        break; 
    380381                                default: 
    381                                         if (_api.jwGetPlaylist()[_api.jwGetItem()] && _api.jwGetPlaylist()[_api.jwGetItem()].provider == "sound") { 
    382                                                 if (_utils.isMobile()) { 
     382                                        if (_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()] && _api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].provider == "sound") { 
     383                                                if (_utils.isIPod()) { 
    383384                                                        _resetPoster(); 
    384385                                                        _showing = false; 
     
    401402                 
    402403                function _showImage() { 
    403                         if (_api.jwGetPlaylist()[_api.jwGetItem()] && _api.jwGetPlaylist()[_api.jwGetItem()].image) { 
     404                        if (_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()] && _api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].image) { 
    404405                                _css(_display.display_image, { 
    405406                                        display: "block" 
    406407                                }); 
    407                                 _display.display_image.src = _utils.getAbsolutePath(_api.jwGetPlaylist()[_api.jwGetItem()].image); 
     408                                _display.display_image.src = _utils.getAbsolutePath(_api.jwGetPlaylist()[_api.jwGetPlaylistIndex()].image); 
    408409                        } 
    409410                } 
  • branches/fl5_instream/js/src/html5/jwplayer.html5.instream.js

    r2043 r2047  
    88        var _utils = jwplayer.utils; 
    99         
    10         jwplayer.html5.instream = function(item, options, api, model, view, controller) { 
    11                 var _item = new jwplayer.html5.playlistitem(item), 
    12                         _api = api, 
    13                         _options = options, 
    14                         _model = model, 
    15                         _view = view, 
    16                         _controller = controller, 
    17                         _currentItem = _model.item, 
    18                         _currentPlaylist = _model.playlist, 
    19                         _video, _oldsrc, _oldsources, _oldpos, 
    20                         _self = this, 
    21                         _provider, _cbar, 
     10        jwplayer.html5.instream = function(api, model, view, controller) { 
     11                var _defaultOptions = { 
     12                        controlbarseekable:"always", 
     13                        controlbarpausable:true, 
     14                        controlbarstoppable:true, 
     15                        playlistclickable:true 
     16                }; 
     17                 
     18                var _item, 
     19                        _options, 
     20                        _api=api, _model=model, _view=view, _controller=controller, 
     21                        _video, _oldsrc, _oldsources, _oldpos, _oldstate, _olditem, 
     22                        _provider, _cbar, _disp, _instreamMode = false, 
     23                        _dispatcher, _instreamContainer, 
     24                        _self = this; 
     25 
     26 
     27                /***************************************** 
     28                 *****  Public instream API methods  ***** 
     29                 *****************************************/ 
     30 
     31                /** Load an instream item and initialize playback **/ 
     32                this.load = function(item, options) { 
     33                        // Update the instream player's model 
     34                        _copyModel(); 
     35                        // Sets internal instream mode to true 
     36                        _instreamMode = true; 
     37                        // Instream playback options 
     38                        _options = _utils.extend(_defaultOptions, options); 
     39                        // Copy the playlist item passed in and make sure it's formatted as a proper playlist item 
     40                        _item = jwplayer.html5.playlistitem(item); 
     41                        // Create (or reuse) video media provider.  No checks right now to make sure it's a valid playlist item (i.e. provider="video"). 
     42                        _setupProvider(); 
     43                        // Create the container in which the controls will be placed 
     44                        _instreamContainer = document.createElement("div"); 
     45                        _instreamContainer.id = _self.id + "_instream_container"; 
     46                        // Get the video tag, and make sure the original player's provider stops broadcasting events (pseudo-lock...) 
     47                        _video = _controller.detachMedia(); 
     48                        // Store this to compare later (in case the main player switches to the next playlist item when we switch out of instream playback mode  
     49                        _olditem = _model.playlist[_model.item]; 
     50                        // Keep track of the original player state 
     51                        _oldstate = _api.jwGetState(); 
     52                        // If the player's currently playing, pause the video tag 
     53                        if (_oldstate == jwplayer.api.events.state.BUFFERING || _oldstate == jwplayer.api.events.state.PLAYING) { 
     54                                _video.pause(); 
     55                        } 
     56                         
     57                        // Copy the video src/sources tags and store the current playback time 
     58                        _oldsrc = _video.src; 
     59                        _oldsources = _video.innerHTML; 
     60                        _oldpos = _video.currentTime; 
     61                         
     62                        // Instream display component 
     63                        _disp = new jwplayer.html5.display(_self, _utils.extend({},_model.plugins.config.display)); 
     64                        _instreamContainer.appendChild(_disp.getDisplayElement()); 
     65 
     66                        // Instream controlbar (if not iOS/Android) 
     67                        if (!_utils.isMobile()) { 
     68                                _cbar = new jwplayer.html5.controlbar(_self, _utils.extend({},_model.plugins.config.controlbar, {})); 
     69                                _instreamContainer.appendChild(_cbar.getDisplayElement()); 
     70                        } 
     71 
     72                        // Show the instream layer 
     73                        _view.setupInstream(_instreamContainer); 
     74                        // Resize the instream components to the proper size 
     75                        _resize(_model.plugins.config.display.width, _model.plugins.config.display.height); 
     76                        // Load the instream item and begin playback 
     77                        _provider.load(_item); 
     78                } 
     79                         
     80                /** Stop the instream playback and revert the main player back to its original state **/ 
     81                this.jwInstreamDestroy = function(complete) { 
     82                        if (!_instreamMode) return; 
     83                        // We're not in instream mode anymore. 
     84                        _instreamMode = false; 
     85                        // Load the original item into our provider, which sets up the regular player's video tag 
     86                        _provider.load(_olditem, false); 
     87                        // We don't want the position interval to be running anymore 
     88                        _provider.stop(false); 
     89                        // We don't want the instream provider to be attached to the video tag anymore 
     90                        _provider.detachMedia(); 
     91                        // Return the view to its normal state 
     92                        _view.destroyInstream(); 
     93                        // Let listeners know the instream player has been destroyed, and why 
     94                        _sendEvent(jwplayer.api.events.JWPLAYER_INSTREAM_DESTROYED, {reason:(complete ? "complete":"destroyed")}, true); 
     95                        // Re-attach the controller 
     96                        _controller.attachMedia(); 
     97                        if (_oldstate == jwplayer.api.events.state.BUFFERING || _oldstate == jwplayer.api.events.state.PLAYING) { 
     98                                // Model was already correct; just resume playback 
     99                                _video.play(); 
     100                                if (_model.playlist[_model.item] == _olditem) { 
     101                                        // We need to seek using the player's real provider, since the seek may have to be delayed 
     102                                        _model.getMedia().seek(_oldpos); 
     103                                } 
     104                        } 
     105                        return; 
     106                }; 
     107                 
     108                /** Forward any calls to add and remove events directly to our event dispatcher **/ 
     109                this.jwInstreamAddEventListener = function(type, listener) { 
     110                        _dispatcher.addEventListener(type, listener); 
     111                }  
     112                this.jwInstreamRemoveEventListener = function(type, listener) { 
     113                        _dispatcher.removeEventListener(type, listener); 
     114                } 
     115 
     116                /** Start instream playback **/ 
     117                this.jwInstreamPlay = function() { 
     118                        if (!_instreamMode) return; 
     119                        _provider.play(true); 
     120                } 
     121 
     122                /** Pause instream playback **/ 
     123                this.jwInstreamPause = function() { 
     124                        if (!_instreamMode) return; 
     125                        _provider.pause(true); 
     126                } 
     127                 
     128                /** Seek to a point in instream media **/ 
     129                this.jwInstreamSeek = function(position) { 
     130                        if (!_instreamMode) return; 
     131                        _provider.seek(position); 
     132                } 
     133                 
     134                /** Get the current instream state **/ 
     135                this.jwInstreamGetState = function() { 
     136                        if (!_instreamMode) return undefined; 
     137                        return _fakemodel.state; 
     138                } 
     139 
     140                /** Get the current instream playback position **/ 
     141                this.jwInstreamGetPosition = function() { 
     142                        if (!_instreamMode) return undefined; 
     143                        return _fakemodel.position; 
     144                } 
     145 
     146                /** Get the current instream media duration **/ 
     147                this.jwInstreamGetDuration = function() { 
     148                        if (!_instreamMode) return undefined; 
     149                        return _fakemodel.duration; 
     150                } 
     151                 
     152                this.playlistClickable = function() { 
     153                        return (!_instreamMode || _options.playlistclickable.toString().toLowerCase()=="true"); 
     154                } 
     155                 
     156 
     157                /***************************** 
     158                 ****** Private methods ******  
     159                 *****************************/ 
     160 
     161                function _init() { 
     162                        // Initialize the instream player's model copied from main player's model 
     163                        _fakemodel = new jwplayer.html5.model(this, _model.getMedia() ? _model.getMedia().getDisplayElement() : _model.container, _model); 
     164                        // Create new event dispatcher 
    22165                        _dispatcher = new jwplayer.html5.eventdispatcher(); 
    23                  
    24  
    25                 function _init() { 
    26                         var _thing = document.createElement("div"); 
    27                         _thing.id = _self.id; 
    28  
    29                         _controller.pause(); 
    30                         _video = _controller.detachMedia(); 
    31 //                      _video.style.zIndex = 10; 
    32  
    33                          
    34                         _oldsrc = _video.src; 
    35                         _oldsources = _video.getElementsByTagName("source"); 
    36                         _oldpos = _video.currentPosition; 
    37                          
    38                         _view.setupInstream(_thing); 
    39  
    40                         _setupProvider(); 
    41                          
    42                         _cbar = new jwplayer.html5.controlbar(_self, _utils.extend({},_model.plugins.config.controlbar, {position:"OVER"})); 
    43                          
    44                         _thing.appendChild(_cbar.getDisplayElement()); 
    45                          
    46                          
    47                         _resize(_api.jwGetWidth(), _api.jwGetHeight()); 
    48  
    49                         _provider.load(_item); 
    50                          
    51                         return; 
    52                 }; 
     166                        // Listen for player resize events 
     167                        _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_RESIZE, function(evt) { 
     168                                _resize(evt.width, evt.height); 
     169                        }); 
     170                        _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_FULLSCREEN, function(evt) { 
     171                                _resize(evt.width, evt.height); 
     172                        }); 
     173                } 
     174 
     175                function _copyModel() { 
     176                        _fakemodel.mute = _model.mute; 
     177                        _fakemodel.volume = _model.volume; 
     178                } 
    53179                 
    54180                function _setupProvider() { 
    55                         _provider = new jwplayer.html5.mediavideo(_model, _model.getMedia() ? _model.getMedia().getDisplayElement() : _model.container); 
    56                         _provider.addGlobalListener( 
    57                                 function(evt) { 
    58                                         _dispatcher.sendEvent(evt.type, evt); 
     181                        if (!_provider) { 
     182                                _provider = new jwplayer.html5.mediavideo(_fakemodel, _model.getMedia() ? _model.getMedia().getDisplayElement() : _model.container); 
     183                                _provider.addGlobalListener(_forward); 
     184                                _provider.addEventListener(jwplayer.api.events.JWPLAYER_MEDIA_META, _metaHandler); 
     185                                _provider.addEventListener(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE, _completeHandler); 
     186                        } 
     187                        _provider.attachMedia(); 
     188                } 
     189                 
     190                /** Forward provider events to listeners **/             
     191                function _forward(evt) { 
     192                        if (_instreamMode) { 
     193                                _sendEvent(evt.type, evt); 
     194                        } 
     195                } 
     196                 
     197                /** Handle the JWPLAYER_MEDIA_COMPLETE event **/                 
     198                function _completeHandler(evt) { 
     199                        if (_instreamMode) { 
     200                                setTimeout(function() { 
     201                                        _self.jwInstreamDestroy(true); 
     202                                }, 10); 
     203                        } 
     204                } 
     205                 
     206                /** Handle the JWPLAYER_MEDIA_META event **/             
     207                function _metaHandler(evt) { 
     208                        // If we're getting video dimension metadata from the provider, allow the view to resize the media 
     209                        if (evt.metadata.width && evt.metadata.height) { 
     210                                _view.resizeMedia(); 
     211                        } 
     212                } 
     213                 
     214                function _sendEvent(type, data, forceSend) { 
     215                        if (_instreamMode || forceSend) { 
     216                                _dispatcher.sendEvent(type, data); 
     217                        } 
     218                } 
     219                 
     220                // Resize handler; resize the components. 
     221                function _resize(width, height) { 
     222                        if (_cbar) { 
     223                                var originalBar = _view.getComponentPosition('controlbar'); 
     224                                _css(_cbar.getDisplayElement(), _utils.extend({}, originalBar, { 
     225                                        position: "absolute", 
     226                                        zIndex: 1001 
     227                                })); 
     228                                _cbar.resize(originalBar.width, originalBar.height); 
     229                        } 
     230                        if (_disp) { 
     231                                var originalDisp = _view.getComponentPosition('display'); 
     232                                _css(_disp.getDisplayElement(), _utils.extend({}, originalDisp, { 
     233                                        position: "absolute", 
     234                                        zIndex: 1000 
     235                                })); 
     236                                _disp.resize(originalDisp.width, originalDisp.height); 
     237                        } 
     238                        if (_view) { 
     239                                _view.resizeMedia(); 
     240                        } 
     241                } 
     242                 
     243                 
     244                /************************************** 
     245                 *****  Duplicate main html5 api  ***** 
     246                 **************************************/ 
     247                 
     248                this.jwPlay = function(state) { 
     249                        if (_options.controlbarpausable.toString().toLowerCase()=="true") { 
     250                                this.jwInstreamPlay(); 
     251                        } 
     252                }; 
     253                 
     254                this.jwPause = function(state) { 
     255                        if (_options.controlbarpausable.toString().toLowerCase()=="true") { 
     256                                this.jwInstreamPause(); 
     257                        } 
     258                }; 
     259 
     260                this.jwStop = function() { 
     261                        if (_options.controlbarstoppable.toString().toLowerCase()=="true") { 
     262                                this.jwInstreamDestroy(); 
     263                        } 
     264                }; 
     265 
     266                this.jwSeek = function(position) { 
     267                        switch(_options.controlbarseekable.toLowerCase()) { 
     268                        case "always": 
     269                                this.jwInstreamSeek(position); 
     270                                break; 
     271                        case "backwards": 
     272                                if (_fakemodel.position > position) { 
     273                                        this.jwInstreamSeek(position); 
    59274                                } 
    60                         ); 
    61                         _provider.addEventListener(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE, function(evt) { 
    62                                 _self.jwInstreamDestroy(); 
    63                         }); 
    64                 } 
    65                  
    66                 function _resize(width, height) { 
    67                         _css(_cbar.getDisplayElement(), { 
    68                                 position: "absolute", 
    69                                 width: width, 
    70                                 height: height, 
    71                                 zIndex: 1000 
    72                         }); 
    73                         _cbar.resize(width, height); 
    74                 } 
    75                  
    76                 this.jwInstreamAddEventListener = _dispatcher.addEventListener;  
    77                 this.jwInstreamRemoveEventListener = _dispatcher.removeEventListener;  
    78                  
    79                 this.jwInstreamPlay = function() { 
    80                 } 
    81  
    82                 this.jwInstreamPause = function() { 
    83                 } 
    84                  
    85                 this.jwInstreamSeek = function(position) { 
    86                 } 
    87  
    88                  
    89                 this.jwInstreamGetState = function() { 
    90                 } 
    91  
    92                 this.jwInstreamGetPosition = function() { 
    93                 } 
    94  
    95                 this.jwInstreamGetDuration = function() { 
    96                 } 
    97  
    98                 this.jwInstreamDestroy = function() { 
    99                         _video.pause(); 
    100                         _video.src = _oldsrc; 
    101                         for (var i=0; i < _oldsources.length; i++) { 
    102                                 _video.appendChild(_oldsources[i]); 
    103                         } 
    104                         _video.currentPosition = _oldpos; 
    105                         _video.load(); 
    106                         _view.destroyInstream(); 
    107                          
    108                         _controller.attachMedia(); 
    109 //                      _model.getMedia().load(_currentPlaylist[_currentItem]); 
    110 //                      _video.pause(); 
    111                         //_utils.setOuterHTML(_video, _videoHTML); 
    112                 } 
    113                  
    114                  
    115                 /** Duplicate main html5 api **/ 
    116                 this.skin = _api.skin; 
    117                  
    118                 this.jwPlay = function(state) {}; 
    119                 this.jwPause = function(state) {}; 
    120                 this.jwSeek = function(position) {}; 
    121                 this.jwStop = function() {}; 
    122                 this.jwGetItem = function() {}; 
     275                                break; 
     276                        } 
     277                }; 
     278                 
    123279                this.jwGetPosition = function() {}; 
    124280                this.jwGetDuration = function() {}; 
    125  
    126281                this.jwGetWidth = _api.jwGetWidth; 
    127282                this.jwGetHeight = _api.jwGetHeight; 
    128  
    129283                this.jwGetFullscreen = _api.jwGetFullscreen; 
    130284                this.jwSetFullscreen = _api.jwSetFullscreen; 
    131  
    132                 this.jwGetVolume = _api.jwGetVolume; 
    133                 this.jwSetVolume = _api.jwSetVolume; 
    134  
    135                 this.jwGetMute = _api.jwGetMute; 
    136                 this.jwSetMute = _api.setMute; 
    137  
    138                 this.jwGetState = function() {}; 
    139                  
    140                 this.jwGetPlaylist = function() { 
    141                         return [_item]; 
    142                 }; 
    143                 this.jwGetPlaylistIndex = function() { 
    144                         return 0; 
    145                 }; 
    146                  
    147                 this.jwAddEventListener = function(type, handler) { 
    148                         _dispatcher.addEventListener(type, handler); 
    149                 } 
    150                 this.jwRemoveEventListener = _dispatcher.removeEventListener; 
    151                  
     285                this.jwGetVolume = function() { return _model.volume; }; 
     286                this.jwSetVolume = function(vol) { 
     287                        _provider.volume(vol); 
     288                        _api.jwSetVolume(vol); 
     289                } 
     290                this.jwGetMute = function() { return _model.mute; }; 
     291                this.jwSetMute = function(state) { 
     292                        _provider.mute(state); 
     293                        _api.jwSetMute(state); 
     294                } 
     295                this.jwGetState = function() { return _fakemodel.state; }; 
     296                this.jwGetPlaylist = function() { return [_item]; }; 
     297                this.jwGetPlaylistIndex = function() { return 0; }; 
     298                this.jwGetStretching = function() { return _model.config.stretching; }; 
     299                this.jwAddEventListener = function(type, handler) { _dispatcher.addEventListener(type, handler); }; 
     300                this.jwRemoveEventListener = function(type, handler) { _dispatcher.removeEventListener(type, handler); }; 
     301 
     302                this.skin = _api.skin; 
    152303                this.id = _api.id; 
    153                  
     304 
    154305                _init(); 
    155                  
    156306                return this; 
    157307        }; 
  • branches/fl5_instream/js/src/html5/jwplayer.html5.mediavideo.js

    r2043 r2047  
    1717        var _utils = jwplayer.utils; 
    1818        var _isMobile = _utils.isMobile(); 
     19         
     20        var _allvideos = {}; 
    1921         
    2022        jwplayer.html5.mediavideo = function(model, container) { 
     
    5860                        _currentItem, 
    5961                        _interval, 
     62                        _delayedSeek,  
    6063                        _emptied = false, 
    6164                        _attached = false, 
     
    109112                                _video.src = item.file; 
    110113                        } 
     114                        _video.style.display = "block"; 
     115                        _video.volume = _model.volume / 100; 
     116                        _video.muted = _model.mute; 
    111117                        if (_isMobile) { 
    112                                 if (item.image) { 
    113                                         _video.poster = item.image; 
    114                                 } 
    115                                 _video.style.display = "block"; 
    116                                 setTimeout(function() { 
    117                                         _video.setAttribute("controls", "controls"); 
    118                                 }, 100); 
     118                                _setControls(); 
    119119                        } 
    120120                         
     
    125125                                item.start = 0; 
    126126                        } 
    127                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_LOADED); 
     127                        _delayedSeek = (item.start > 0) ? item.start : -1; 
     128                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_LOADED); 
    128129                        if((!_isMobile && item.levels.length == 1) || !_emptied) { 
    129130                                _video.load(); 
     
    132133                        if (play) { 
    133134                                _setState(jwplayer.api.events.state.BUFFERING); 
    134                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER, { 
     135                                _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER, { 
    135136                                        bufferPercent: 0 
    136137                                }); 
     
    145146                        if (!_attached) return; 
    146147                         
    147                         if (_state != jwplayer.api.events.state.PLAYING) { 
    148                                 _startInterval(); 
    149                                 if (_bufferFull) { 
    150                                         _setState(jwplayer.api.events.state.PLAYING); 
    151                                 } else { 
    152                                         _setState(jwplayer.api.events.state.BUFFERING); 
    153                                 } 
    154                                 _video.play(); 
    155                         } 
     148                        _startInterval(); 
     149                        if (_bufferFull) { 
     150                                _setState(jwplayer.api.events.state.PLAYING); 
     151                        } else { 
     152                                _setState(jwplayer.api.events.state.BUFFERING); 
     153                        } 
     154                        _video.play(); 
    156155                } 
    157156                 
     
    172171                this.seek = function(position) { 
    173172                        if (!_attached) return; 
    174                          
    175                         if (!(_model.duration <= 0 || isNaN(_model.duration)) && 
    176                                 !(_model.position <= 0 || isNaN(_model.position))) { 
    177                                         _video.currentTime = position; 
    178                                         _video.play(); 
     173                        if (!_start && _video.readyState > 0) { 
     174                                if (!(_model.duration <= 0 || isNaN(_model.duration)) && 
     175                                                !(_model.position <= 0 || isNaN(_model.position))) { 
     176                                                _video.currentTime = position; 
     177                                                _video.play(); 
     178                                } 
     179                        } else { 
     180                                _delayedSeek = position; 
    179181                        } 
    180182                } 
     
    204206                                        _video.removeAttribute("src"); 
    205207                                } 
    206                                 _video.removeAttribute("controls"); 
    207                                 _video.removeAttribute("poster"); 
     208                                _hideControls(); 
    208209                                _utils.empty(_video); 
    209210                                _video.load(); 
     
    229230                /** Resize the player. **/ 
    230231                this.resize = function(width, height) { 
    231 //                      _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_RESIZE, { 
     232//                      _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_RESIZE, { 
    232233//                              fullscreen: _model.fullscreen, 
    233234//                              width: width, 
     
    240241                        if (!_isMobile) { 
    241242                                _video.volume = position / 100; 
    242                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_VOLUME, { 
     243                                _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_VOLUME, { 
    243244                                        volume: (position / 100) 
    244245                                }); 
     
    251252                        if (!_isMobile) { 
    252253                                _video.muted = state; 
    253                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, { 
     254                                _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, { 
    254255                                        mute: state 
    255256                                }); 
     
    293294                function _handleMediaEvent(type, handler) { 
    294295                        return function(evt) { 
    295                                 if (_attached && _utils.exists(evt.target.parentNode)) { 
     296                                if (_utils.exists(evt.target.parentNode)) { 
    296297                                        handler(evt); 
    297298                                } 
     
    301302                /** Initializes the HTML5 video and audio media provider **/ 
    302303                function _init() { 
    303                         if (!_video) { 
    304                                 if (_container.tagName.toLowerCase() == "video") { 
    305                                         _video = _container; 
    306                                 } else { 
    307                                         _video = document.createElement("video"); 
    308                                 } 
    309                         } 
    310304                        _state = jwplayer.api.events.state.IDLE; 
    311305  
    312                         for (var event in _events) { 
    313                                 _video.addEventListener(event, _handleMediaEvent(event, _events[event]), true); 
    314                         } 
    315306                        _attached = true; 
     307                         
     308                        _video = _getVideoElement(); 
    316309 
    317310                        _video.setAttribute("x-webkit-airplay", "allow");  
     
    324317                                _video.id = _container.id; 
    325318                        } 
    326                          
    327                         _video.volume = _model.volume / 100; 
     319                } 
     320                 
     321                function _getVideoElement() { 
     322                        var vid; 
     323                        if (!_allvideos[_model.id]) { 
     324                                if (_container.tagName.toLowerCase() == "video") { 
     325                                        vid = _container; 
     326                                } else { 
     327                                        vid = document.createElement("video"); 
     328                                } 
     329                                for (var event in _events) { 
     330                                        vid.addEventListener(event, _handleMediaEvent(event, _events[event]), true); 
     331                                } 
     332                                _allvideos[_model.id] = vid; 
     333                        } 
     334                        return _allvideos[_model.id]; 
    328335                } 
    329336                 
     
    335342                        } 
    336343 
     344                        if (_isMobile) { 
     345                                switch (newstate) { 
     346                                case jwplayer.api.events.state.PLAYING: 
     347                                        _setControls(); 
     348                                        break; 
     349                                default: 
     350                                        _hideControls(); 
     351                                        break; 
     352                                } 
     353                        } 
     354                         
    337355                        if (_state != newstate) { 
    338356                                var oldstate = _state; 
    339357                                _model.state = _state = newstate; 
    340                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_PLAYER_STATE, { 
     358                                _sendEvent(jwplayer.api.events.JWPLAYER_PLAYER_STATE, { 
    341359                                        oldstate: oldstate, 
    342360                                        newstate: newstate 
     
    353371                function _volumeHandler(event) { 
    354372                        var newVol = Math.round(_video.volume * 100); 
    355                         if (newVol != _model.volume) { 
    356                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_VOLUME, { 
    357                                         volume: newVol 
    358                                 }); 
    359                         } 
    360                         if (_video.muted != _model.mute) { 
    361                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, { 
    362                                         mute: _video.muted 
    363                                 }); 
    364                         } 
     373                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_VOLUME, { 
     374                                volume: newVol 
     375                        }, true); 
     376                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_MUTE, { 
     377                                mute: _video.muted 
     378                        }, true); 
    365379                } 
    366380 
    367381                /** Update the player progress **/ 
    368382                function _progressHandler(event) { 
     383                        if (!_attached) return; 
     384 
    369385                        var bufferPercent; 
    370386                        if (_utils.exists(event) && event.lengthComputable && event.total) { 
     
    378394                         
    379395                        if (_bufferFull === false && _state == jwplayer.api.events.state.BUFFERING) { 
    380                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER_FULL); 
     396                                _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER_FULL); 
    381397                                _bufferFull = true; 
    382398                        } 
     
    389405                                if (_utils.exists(bufferPercent) && (bufferPercent > _model.buffer)) { 
    390406                                        _model.buffer = Math.round(bufferPercent); 
    391                                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER, { 
     407                                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_BUFFER, { 
    392408                                                bufferPercent: Math.round(bufferPercent) 
    393409                                        }); 
     
    399415                /** Update the player's position **/ 
    400416                function _positionHandler(event) { 
     417                        if (!_attached) return; 
     418 
    401419                        if (_utils.exists(event) && _utils.exists(event.target)) { 
    402                                 if (!isNaN(event.target.duration) && (isNaN(_model.duration) || _model.duration < 1)) { 
    403                                         if (event.target.duration == Infinity) { 
    404                                                 _model.duration = 0; 
    405                                         } else { 
    406                                                 _model.duration = Math.round(event.target.duration * 10) / 10; 
     420                                if (_userDuration > 0) { 
     421                                        if (!isNaN(event.target.duration) && (isNaN(_model.duration) || _model.duration < 1)) { 
     422                                                if (event.target.duration == Infinity) { 
     423                                                        _model.duration = 0; 
     424                                                } else { 
     425                                                        _model.duration = Math.round(event.target.duration * 10) / 10; 
     426                                                } 
    407427                                        } 
    408428                                } 
    409429                                if (!_start && _video.readyState > 0) { 
    410                                         _video.style.display = "block"; 
    411430                                        _setState(jwplayer.api.events.state.PLAYING); 
    412431                                } 
    413432                                 
    414433                                if (_state == jwplayer.api.events.state.PLAYING) { 
    415                                         if (!_start && _video.readyState > 0) { 
     434                                        if (_video.readyState > 0 && (_delayedSeek > -1 || !_start)) { 
    416435                                                _start = true; 
    417436                                                try { 
    418                                                         if (_video.currentTime < _currentItem.start) { 
    419                                                                 _video.currentTime = _currentItem.start; 
     437                                                        if (_video.currentTime != _delayedSeek && _delayedSeek > -1) { 
     438                                                                _video.currentTime = _delayedSeek; 
     439                                                                _delayedSeek = -1; 
    420440                                                        } 
    421441                                                } catch (err) {} 
     
    424444                                        } 
    425445                                        _model.position = _model.duration > 0 ? (Math.round(event.target.currentTime * 10) / 10) : 0; 
    426                                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_TIME, { 
     446                                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_TIME, { 
    427447                                                position: _model.position, 
    428448                                                duration: _model.duration 
     
    441461 
    442462                function _stateHandler(event) { 
     463                        if (!_attached) return; 
     464 
    443465                        if (_states[event.type]) { 
    444466                                if (event.type == "ended") { 
     
    451473 
    452474                function _metaHandler(event) { 
     475                        if (!_attached) return; 
    453476                        var newDuration = Math.round(event.target.duration * 10) / 10; 
    454477                        var meta = { 
     
    462485                                } 
    463486                        } 
    464                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_META, { 
     487                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_META, { 
    465488                                metadata: meta 
    466489                        }); 
     
    468491 
    469492                function _errorHandler(event) { 
     493                        if (!_attached) return; 
     494 
    470495                        if (_state == jwplayer.api.events.state.IDLE) { 
    471496                                return; 
     
    506531                        message += _joinFiles(); 
    507532                        _error = true; 
    508                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_ERROR, { 
     533                        _sendEvent(jwplayer.api.events.JWPLAYER_ERROR, { 
    509534                                message: message 
    510535                        }); 
     
    540565                 
    541566                function _complete() { 
    542                         if (_state != jwplayer.api.events.state.IDLE) { 
     567                        if (_state == jwplayer.api.events.state.PLAYING) { 
    543568                                _stop(false); 
    544                                 _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE); 
     569                                setTimeout(function() { 
     570                                        _sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_COMPLETE); 
     571                                }, 10); 
    545572                        } 
    546573                } 
     
    550577                                if (_model.fullscreen && !_video.webkitDisplayingFullscreen) { 
    551578                                        //_model.fullscreen = _video.webkitDisplayingFullscreen; 
    552                                         _eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_FULLSCREEN, { 
     579                                        _sendEvent(jwplayer.api.events.JWPLAYER_FULLSCREEN, { 
    553580                                                fullscreen: false 
    554                                         }); 
     581                                        },true); 
    555582                                } 
    556583                        } 
     
    576603                } 
    577604                 
     605                function _setControls() { 
     606                        if (_currentItem.image) { 
     607                                _video.poster = _currentItem.image; 
     608                        } 
     609                        setTimeout(function() { 
     610                                _video.setAttribute("controls", "controls"); 
     611                        }, 100); 
     612                } 
     613                 
     614                function _hideControls() { 
     615                        _video.removeAttribute("controls"); 
     616                        _video.removeAttribute("poster"); 
     617                } 
     618                 
     619                function _sendEvent(type, obj, alwaysSend) { 
     620                        if (_attached || alwaysSend) { 
     621                                if (obj) { 
     622                                        _eventDispatcher.sendEvent(type, obj); 
     623                                } else { 
     624                                        _eventDispatcher.sendEvent(type); 
     625                                } 
     626                        } 
     627                } 
     628                 
    578629        }; 
    579630})(jwplayer); 
  • branches/fl5_instream/js/src/html5/jwplayer.html5.view.js

    r2043 r2047  
    2323                var _falseFullscreen = false; 
    2424                var _normalscreenWidth, _normalscreenHeight; 
    25                 var _instremArea; 
     25                var _instremArea, _instreamMode; 
    2626                 
    2727                function createWrapper() { 
     
    105105                 
    106106                function _stateHandler(evt) { 
    107                         _css(_box, { 
    108                                 display: (_model.getMedia() && _model.getMedia().hasChrome() && evt.newstate != jwplayer.api.events.state.IDLE) ? "none" : "block" 
    109                         }); 
     107                        if (_instreamMode) { return; } 
     108                         
     109                        if (_model.getMedia() && _model.getMedia().hasChrome()) { 
     110                                _box.style.display = "block"; 
     111                        } else { 
     112                                switch (evt.newstate) { 
     113                                case evt.newstate == jwplayer.api.events.state.PLAYING: 
     114                                        _box.style.display = "none"; 
     115                                        break; 
     116                                default: 
     117                                        _box.style.display = "block"; 
     118                                        break; 
     119                                } 
     120                        } 
    110121                } 
    111122 
     
    138149                        _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_PLAYER_STATE, _stateHandler); 
    139150                        _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_MEDIA_LOADED, _loadedHandler); 
    140                         _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_MEDIA_META, function() { 
     151                        _api.jwAddEventListener(jwplayer.api.events.JWPLAYER_MEDIA_META, function(evt) { 
    141152                                _resizeMedia(); 
    142153                        }); 
     
    315326                } 
    316327                 
    317                 function _resizeMedia() { 
     328                var _resizeMedia = this.resizeMedia = function() { 
    318329                        if (!_utils.exists(_model.getMedia())) { 
    319330                                return; 
     
    361372                } 
    362373                 
    363                 function _getComponentPosition(pluginName) { 
     374                var _getComponentPosition = this.getComponentPosition = function(pluginName) { 
    364375                        var plugincss = { 
    365376                                position: "absolute", 
     
    486497                        return false; 
    487498                } 
    488                 ///             public function setupInstream(_instreamDisplay:DisplayObject, plugin:IPlugin):void { 
    489499                 
    490500                this.setupInstream = function(instreamDisplay) { 
     
    492502                        _box.style.display = "none"; 
    493503                        _instreamArea.appendChild(instreamDisplay); 
    494                 } 
    495                  
    496                 ///                     public function destroyInstream():void { 
     504                        _instreamMode = true; 
     505                } 
     506                 
    497507                var _destroyInstream = this.destroyInstream = function() { 
    498508                        _instreamArea.style.display = "none"; 
     509                        _instreamArea.innerHTML = ""; 
    499510                        _box.style.display = "block"; 
     511                        _instreamMode = false; 
     512                        _resize(_model.width, _model.height); 
    500513                } 
    501514        }; 
    502515         
    503516         
    504         //TODO: Enum 
    505517        jwplayer.html5.view.positions = { 
    506518                TOP: "TOP", 
  • branches/fl5_instream/js/src/jwplayer.js

    r2043 r2047  
    1111var $jw = jwplayer; 
    1212 
    13 jwplayer.version = '5.9.2043'; 
     13jwplayer.version = '5.9.2047'; 
    1414 
    1515// "Shiv" method for older IE browsers; required for parsing media tags 
  • branches/fl5_instream/js/test/examples/instream.html

    r2043 r2047  
    11<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
    22<html> 
    3     <head> 
    4         <title>Instream API Example</title> 
    5         <script type="text/javascript" src="../../bin-debug/jwplayer.js"> 
     3<head> 
     4<title>Instream API Example</title> 
     5<script type="text/javascript" src="../../bin-debug/jwplayer.js"> 
    66        </script> 
    7         <script type="text/javascript" src="settings.js"> 
     7<script type="text/javascript" src="settings.js"> 
    88        </script> 
    9             <style type="text/css"> 
    10                 form { 
    11                         margin-bottom: 15px; 
    12                         overflow: hidden; 
    13                 } 
    14                 formset { 
    15                         display:block; 
    16                         float:left; 
    17                         margin-right: 15px 
    18                 } 
    19             </style> 
    20     </head> 
    21     <body> 
    22         <script type="text/javascript"> 
     9<style type="text/css"> 
     10form { 
     11        margin-bottom: 15px; 
     12        overflow: hidden; 
     13} 
     14 
     15formset { 
     16        display: block; 
     17        float: left; 
     18        margin-right: 15px 
     19} 
     20</style> 
     21</head> 
     22<body> 
     23<script type="text/javascript"> 
    2324            document.write("<h1>" + document.title + "</h1>"); 
    2425        </script> 
    2526 
    26           <form> 
    27           <formset> 
    28                 <h3>Player Options</h3> 
    29             <label>Rendering mode</label> 
    30             <select id="mode"> 
    31               <option id="mode_flashonly" value="flashonly" selected="selected">Flash Only</option> 
    32               <option id="mode_html5only" value="html5only">HTML5 Only</option> 
    33             </select><br/> 
    34             <label>Instream Timing</label> 
    35             <select id="timing" onchange="return setupAll();"> 
    36               <option id="timing_beforeplay" value="beforeplay" selected="selected">onBeforePlay</option> 
    37               <option id="timing_button" value="button">Button click</option> 
    38               <option id="timing_time" value="time">At 5 seconds</option> 
    39               <option id="timing_complete" value="complete">onComplete</option> 
    40             </select><br/> 
    41             <label>Controlbar Position</label> 
    42             <select id="controlbar" onchange="return setupAll();"> 
    43               <option id="controlbar_over" value="over" selected="selected">Over</option> 
    44               <option id="controlbar_bottom" value="bottom">Bottom</option> 
    45               <option id="controlbar_top" value="top">Top</option> 
    46             </select><br/> 
    47             <label>Playlist Position</label> 
    48             <select id="playlist" onchange="return setupAll();"> 
    49               <option id="playlist_none" value="none" selected="selected">None</option> 
    50               <option id="playlist_right" value="right">Right</option> 
    51             </select><br/>             
    52             <label>Repeat</label> 
    53             <select id="repeat" onchange="return setupAll();"> 
    54               <option id="repeat_none" value="none" selected="selected">None</option> 
    55               <option id="repeat_list" value="list">List</option> 
    56               <option id="repeat_always" value="always">Always</option> 
    57               <option id="repeat_single" value="single">Single</option> 
    58             </select><br/>             
    59             <label>Skin</label> 
    60             <select id="skin" onchange="return setupAll();"> 
    61               <option id="skin_" value="" selected="selected">None</option> 
    62               <option id="skin_beelden" value="beelden">Beelden</option> 
    63               <option id="skin_classic" value="classic">Classic</option> 
    64             </select><br/> 
    65             <label>Stretching</label> 
    66             <select id="stretching" onchange="return setupAll();"> 
    67               <option id="stretching_uniform" value="uniform" selected="selected">Uniform</option> 
    68               <option id="stretching_exactfit" value="exactfit">Exactfit</option> 
    69               <option id="stretching_fill" value="fill">Fill</option> 
    70               <option id="stretching_none" value="none">None</option> 
    71             </select> 
    72           </formset>           
    73           <formset> 
    74                 <h3>InStream Options</h3> 
    75             <label>Controlbar Seekable</label> 
    76             <select id="seekable" onchange="return setupAll();"> 
    77               <option id="seekable_always" value="always" selected="selected">Always</option> 
    78               <option id="seekable_never" value="never">Never</option> 
    79               <option id="seekable_backwards" value="backwards">Backwards</option> 
    80             </select><br/> 
    81             <label>Controlbar Pausable</label> 
    82             <select id="pausable" onchange="return setupAll();"> 
    83               <option id="pausable_true" value="true" selected="selected">True</option> 
    84               <option id="pausable_false" value="false">False</option> 
    85             </select><br/> 
    86             <label>Controlbar Stoppable</label> 
    87             <select id="stoppable" onchange="return setupAll();"> 
    88               <option id="stoppable_true" value="true" selected="selected">True</option> 
    89               <option id="stoppable_false" value="false">False</option> 
    90             </select><br/> 
    91             <label>Playlist Clickable</label> 
    92             <select id="playlist_clickable" onchange="return setupAll();"> 
    93               <option id="playlist_clickable_true" value="true" selected="selected">True</option> 
    94               <option id="playlist_clickable_false" value="false">False</option> 
    95             </select><br/> 
    96             <label>Autoload</label> 
    97             <select id="autoload" onchange="return setupAll();"> 
    98               <option id="autoload_false" value="false" selected="selected">False</option> 
    99               <option id="autoload_true" value="true">True</option> 
    100             </select><br/> 
    101           </formset> 
    102           <formset> 
    103                 <h3>Log Events</h3> 
    104                 <label>Action</label> 
    105                 <select id="log"> 
    106                         <option id="log_console" value="console" selected="selected">console.log</option> 
    107                         <option id="log_alert" value="alert">alert</option> 
    108                 </select><br/> 
    109                 <label>Event</label> 
    110                 <select id="events" multiple="multiple" size="10"> 
    111                         <option value="onPlay">onPlay</option> 
    112                         <option value="onPause">onPause</option>  
    113                         <option value="onBuffer">onBuffer</option>  
    114                         <option value="onIdle">onIdle</option>  
    115                         <option value="onComplete">onComplete</option>  
    116                         <option value="onTime">onTime</option>  
    117                         <option value="onSeek">onSeek</option>  
    118                         <option value="onMeta">onMeta</option>  
    119                         <option value="onMute">onMute</option>  
    120                         <option value="onVolume">onVolume</option>  
    121                         <option value="onFullscreen">onFullscreen</option>  
    122                         <option value="onError">onError</option>  
    123                         <option value="onInstreamClick">onInstreamClick</option> 
    124                         <option value="onInstreamDestroyed">onInstreamDestroyed</option> 
    125                 </select> 
    126           </formset>  
    127  
    128             <button id="go" onclick="return setupAll();" style="float:left; clear:left">Update</button> 
    129           </form> 
    130         </p> 
    131          
    132          
    133         <hr/> 
    134          
    135         <div style="width:100%; height:300px; overflow:auto"> 
    136                 <div style="float:left;"> 
    137                         <div height="270" id="player" width="480"> 
    138                                 Player should replace this 
    139                         </div> 
    140                 </div> 
    141                 <div style="float:left; margin-left: 15px;"> 
    142                         <button id="instreamInit" onclick="initInstream();return false;" style="display:none">Click to initialize Instream</button> 
    143                         <div id="instreamActions"> 
    144                                 <label>Instream Controls</label> 
    145                                         <button id="play" onclick="playInstream();return false;">Play</button>                           
    146                                         <button id="pause" onclick="pauseInstream();return false;">Pause</button>                                
    147                                         <button id="seek" onclick="seekInstream(10);return false;">seek(10)</button>                             
    148                                         <button id="getters" onclick="updateGetters();return false;">Update Getters</button> 
    149                                         <button id="destroy" onclick="destroyInstream();return false">Destroy</button> 
    150                                         <br/> 
    151                                         <label>State:</label><span id="state">IDLE</span><br/> 
    152                                         <label>Position:</label><span id="position">0.0</span><br/> 
    153                                         <label>Duration:</label><span id="duration">0.0</span> 
    154                         </div> 
    155                 </div> 
    156         </div> 
    157         <script type="text/javascript"> 
     27<form><formset> 
     28<h3>Player Options</h3> 
     29<label>Rendering mode</label> <select id="mode"> 
     30        <option id="mode_flash" value="flash" selected="selected">Flash 
     31        -> HTML5</option> 
     32        <option id="mode_html5" value="html5">HTML5 -> Flash</option> 
     33</select><br /> 
     34<label>Instream Timing</label> <select id="timing" 
     35        onchange="return setupAll();"> 
     36        <option id="timing_beforeplay" value="beforeplay" selected="selected">onBeforePlay</option> 
     37        <option id="timing_button" value="button">Button click</option> 
     38        <option id="timing_time" value="time">At 5 seconds</option> 
     39        <option id="timing_complete" value="complete">onComplete</option> 
     40</select><br /> 
     41<label>Controlbar Position</label> <select id="controlbar" 
     42        onchange="return setupAll();"> 
     43        <option id="controlbar_over" value="over" selected="selected">Over</option> 
     44        <option id="controlbar_bottom" value="bottom">Bottom</option> 
     45        <option id="controlbar_top" value="top">Top</option> 
     46</select><br /> 
     47<label>Playlist Position</label> <select id="playlist" 
     48        onchange="return setupAll();"> 
     49        <option id="playlist_none" value="none" selected="selected">None</option> 
     50        <option id="playlist_right" value="right">Right</option> 
     51</select><br /> 
     52<label>Repeat</label> <select id="repeat" onchange="return setupAll();"> 
     53        <option id="repeat_none" value="none" selected="selected">None</option> 
     54        <option id="repeat_list" value="list">List</option> 
     55        <option id="repeat_always" value="always">Always</option> 
     56        <option id="repeat_single" value="single">Single</option> 
     57</select><br /> 
     58<label>Skin</label> <select id="skin" onchange="return setupAll();"> 
     59        <option id="skin_" value="" selected="selected">None</option> 
     60        <option id="skin_beelden" value="beelden">Beelden</option> 
     61        <option id="skin_classic" value="classic">Classic</option> 
     62</select><br /> 
     63<label>Stretching</label> <select id="stretching" 
     64        onchange="return setupAll();"> 
     65        <option id="stretching_uniform" value="uniform" selected="selected">Uniform</option> 
     66        <option id="stretching_exactfit" value="exactfit">Exactfit</option> 
     67        <option id="stretching_fill" value="fill">Fill</option> 
     68        <option id="stretching_none" value="none">None</option> 
     69</select> </formset> <formset> 
     70<h3>InStream Options</h3> 
     71<label>Controlbar Seekable</label> <select id="seekable" 
     72        onchange="return setupAll();"> 
     73        <option id="seekable_always" value="always" selected="selected">Always</option> 
     74        <option id="seekable_never" value="never">Never</option> 
     75        <option id="seekable_backwards" value="backwards">Backwards</option> 
     76</select><br /> 
     77<label>Controlbar Pausable</label> <select id="controlbarpausable" 
     78        onchange="return setupAll();"> 
     79        <option id="controlbarpausable_true" value="true" selected="selected">True</option> 
     80        <option id="controlbarpausable_false" value="false">False</option> 
     81</select><br /> 
     82<label>Controlbar Stoppable</label> <select id="controlbarstoppable" 
     83        onchange="return setupAll();"> 
     84        <option id="controlbarstoppable_true" value="true" selected="selected">True</option> 
     85        <option id="controlbarstoppable_false" value="false">False</option> 
     86</select><br /> 
     87<label>Playlist Clickable</label> <select id="playlistclickable" 
     88        onchange="return setupAll();"> 
     89        <option id="playlistclickable_true" value="true" selected="selected">True</option> 
     90        <option id="playlistclickable_false" value="false">False</option> 
     91</select><br /> 
     92<label>Autoload</label> <select id="autoload" 
     93        onchange="return setupAll();"> 
     94        <option id="autoload_false" value="false" selected="selected">False</option> 
     95        <option id="autoload_true" value="true">True</option> 
     96</select><br /> 
     97</formset> <formset> 
     98<h3>Log Events</h3> 
     99<label>Action</label> <select id="log"> 
     100        <option id="log_console" value="console" selected="selected">console.log</option> 
     101        <option id="log_alert" value="alert">alert</option> 
     102</select><br /> 
     103<label>Event</label> <select id="events" multiple="multiple" size="10"> 
     104        <option id="events_onPlay" value="onPlay">onPlay</option> 
     105        <option id="events_onPause" value="onPause">onPause</option> 
     106        <option id="events_onBuffer" value="onBuffer">onBuffer</option> 
     107        <option id="events_onIdle" value="onIdle">onIdle</option> 
     108        <option id="events_onComplete" value="onComplete">onComplete</option> 
     109        <option id="events_onTime" value="onTime">onTime</option> 
     110        <option id="events_onSeek" value="onSeek">onSeek</option> 
     111        <option id="events_onMeta" value="onMeta">onMeta</option> 
     112        <option id="events_onMute" value="onMute">onMute</option> 
     113        <option id="events_onVolume" value="onVolume">onVolume</option> 
     114        <option id="events_onFullscreen" value="onFullscreen">onFullscreen</option> 
     115        <option id="events_onError" value="onError">onError</option> 
     116        <option id="events_onInstreamClick" value="onInstreamClick">onInstreamClick</option> 
     117        <option id="events_onInstreamDestroyed" value="onInstreamDestroyed">onInstreamDestroyed</option> 
     118</select> </formset> 
     119 
     120<button id="go" onclick="return setupAll();" 
     121        style="float: left; clear: left">Update</button> 
     122</form> 
     123</p> 
     124 
     125 
     126<hr /> 
     127 
     128<div style="width: 100%; height: 300px; overflow: auto"> 
     129<div style="float: left;"> 
     130<div height="270" id="player" width="480">Player should replace 
     131this</div> 
     132</div> 
     133<div style="float: left; margin-left: 15px;"> 
     134<button id="instreamInit" onclick="initInstream();return false;" 
     135        style="display: none">Click to initialize Instream</button> 
     136<div id="instreamActions"><label>Instream Controls</label> 
     137<button id="play" onclick="playInstream();return false;">Play</button> 
     138<button id="pause" onclick="pauseInstream();return false;">Pause</button> 
     139<button id="seek" onclick="seekInstream(10);return false;">seek(10)</button> 
     140<button id="getters" onclick="updateGetters();return false;">Update 
     141Getters</button> 
     142<button id="destroy" onclick="destroyInstream();return false">Destroy</button> 
     143<br /> 
     144<label>State:</label><span id="state">IDLE</span><br /> 
     145<label>Position:</label><span id="position">0.0</span><br /> 
     146<label>Duration:</label><span id="duration">0.0</span></div> 
     147</div> 
     148</div> 
     149<script type="text/javascript"> 
    158150                var player = null; 
    159151                var instream = null; 
     
    171163                instreamOptions = { 
    172164                                        controlbarseekable: document.getElementById('seekable').value, 
    173                                         controlbarpausable: document.getElementById('pausable').value, 
    174                                         controlbarstoppable: document.getElementById('stoppable').value, 
    175                                         playlistclickable: document.getElementById('playlist_clickable').value, 
     165                                        controlbarpausable: document.getElementById('controlbarpausable').value, 
     166                                        controlbarstoppable: document.getElementById('controlbarstoppable').value, 
     167                                        playlistclickable: document.getElementById('playlistclickable').value, 
    176168                                        autoload: document.getElementById('autoload').value 
    177169                                }; 
     
    241233                        setupBlock.skin = "../../../../../tags/skins/" + skin + "/" + skin + ".zip"; 
    242234                    } 
    243                  
     235 
     236                if (player) { 
     237                                        player.remove(); 
     238                } 
    244239                player = jwplayer("player").setup(setupBlock); 
    245240                    return false;        
     
    304299 
    305300 
     301                        function setDefaultEvents() { 
     302                                var selectedEvents = getVariable("events").split(','); 
     303                                for (var i=0; i<selectedEvents.length; i++) { 
     304                                        var opt = document.getElementById("events_"+selectedEvents[i]); 
     305                                        if (opt) { 
     306                                                opt.selected = true; 
     307                                        } 
     308                                } 
     309                        } 
     310                         
    306311                        function setupEvents() { 
    307312                                if (!instream) return; 
     313 
     314                                var allOptions = document.getElementById("events").options; 
    308315                                 
    309                                 var allOptions = document.getElementById("events").options; 
    310316                                for (var i=0; i < allOptions.length; i++) { 
    311317                                        var option = allOptions[i]; 
     
    326332                        } 
    327333 
     334                        function getVariable(name) { 
     335                                var regex = new RegExp(name+"=([\\w\\,]+)"); 
     336                                var match = window.location.href.match(regex); 
     337                                if (match && match.length > 1) { 
     338                                        return match[1]; 
     339                                } else { 
     340                                        return ""; 
     341                                } 
     342                        } 
     343                         
    328344                        function setDefault(name) { 
    329                                 var regex = new RegExp(name+"=(\\w+)"); 
    330                                 var val = window.location.href.match(regex); 
    331                                 if (val && val.length==2) { 
    332                                         document.getElementById(name+"_"+val[1]).selected = true; 
    333                                 } 
    334                         }                                
     345                                var val = getVariable(name); 
     346                                if (val) { 
     347                                        document.getElementById(name+"_"+val).selected = true; 
     348                                } 
     349                        } 
    335350 
    336351                        setDefault("timing"); 
     
    343358 
    344359                        setDefault("seekable"); 
    345                         setDefault("pausable"); 
    346                         setDefault("stoppable"); 
    347                         setDefault("playlist_clickable"); 
     360                        setDefault("controlbarpausable"); 
     361                        setDefault("controlbarstoppable"); 
     362                        setDefault("playlistclickable"); 
    348363                        setDefault("autoload"); 
     364                        setDefaultEvents(); 
    349365                         
    350366                        setupAll(); 
    351367        </script> 
    352          
    353         <h3>HTML code</h3> 
    354     </body> 
     368 
     369<h3>HTML code</h3> 
     370</body> 
    355371</html> 
  • branches/fl5_instream/js/test/examples/settings.js

    r1831 r2047  
    2424    html5only: [{type:'html5'}], 
    2525    flashhtml5: [{type:'flash',src:'../../../player.swf'},{type:'html5'}], 
    26     html5flash: [{type:'html5'},{type:'flash',src:'../../../player.swf'}], 
     26    flash: [{type:'flash',src:'../../../player.swf'},{type:'html5'}], 
     27    html5: [{type:'html5'},{type:'flash',src:'../../../player.swf'}], 
    2728    standard: [{type:'flash',src:'../../../player.swf'},{type:'html5'},{type:'download'}] 
    2829 } 
  • branches/fl5_instream/src/com/longtailvideo/jwplayer/player/PlayerVersion.as

    r2043 r2047  
    33         
    44        public class PlayerVersion { 
    5                 protected static var _version:String = '5.9.2043'; 
     5                protected static var _version:String = '5.9.2047'; 
    66                 
    77                public static function get version():String { 
Note: See TracChangeset for help on using the changeset viewer.