Changeset 1218


Ignore:
Timestamp:
08/18/10 11:29:45 (3 years ago)
Author:
pablo
Message:

Updates to JS API and testing tool

Location:
trunk/js
Files:
1 added
2 deleted
8 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/js/bin-debug/embed.html

    r1200 r1218  
    22        <head> 
    33                <script type="text/javascript" src="jquery.js"></script> 
    4                 <script type="text/javascript" src="jquery.jwplayerParse.js"></script> 
    54                <script type="text/javascript" src="jwplayer.js"></script> 
    65                <script type="text/javascript" src="jwplayer.html5.js"></script> 
     
    87                        var options = { 
    98                                image:          '../../../testing/files/bunny.jpg', 
    10                                 plugins:        { 
    11                                         'sharing-1': {}, 
    12                                         'viral-2d': { 
    13                                                 link: 'http://www.longtailvideo.com', 
    14                                                 'allowmenu': 'true' 
    15                                         }, 
    16                                         'fbit-1': {} 
    17                                 }, 
    189                                players: [ 
    1910                                        {type:'html5'}, 
    2011                                        {type:'flash', src: '../../../trunk/fl5/player.swf'}, 
     12                                ], 
     13                                skin: '', 
     14                                levels: [ 
     15                                        {file: '../../../testing/files/bunny.mp4'} 
    2116                                ] 
    2217                        };  
    2318                        function embedPlayer(id) { 
    24                                 return $jw(id).setup(options); 
     19                                $jw(id).setup(options); 
     20                                $jw(id).onPlay(function() { 
     21                                        alert("Playing!"); 
     22                                }); 
    2523                        }        
    2624                </script> 
     
    3028                <h1>JWPlayer JS Embedder Testing Page</h1> 
    3129                <div id="something"> 
    32                         <video id="div1" width=500 height=300> 
    33                                 <source src="../../../testing/files/bunny.mp4" /> 
    34                                 This is &lt;div&gt; 1. 
    35                         </video> 
     30                        <div id="div1"></div> 
    3631                </div> 
    3732                <div id="something_else"> 
     
    4035                        </div> 
    4136                </div> 
    42                 <script type="text/javascript"> 
    43                         embedPlayer('div1'); 
    44                 </script> 
    4537                <h3>Embed a player</h3> 
    46                 <a href="#" onclick="embedPlayer('div2'); return false;">Click here to embed player</a><br /> 
     38                <a href="#" onclick="embedPlayer('div1'); return false;">Click here to embed player</a><br /> 
    4739 
    4840        </body> 
  • trunk/js/bin-debug/jwplayer.html5.js

    r1208 r1218  
    11781178                return function(evt) { 
    11791179                        if (player._media === undefined) { 
    1180                                 document.location.href = jwplayer.html5.utils.getAbsolutePath(player.getPlaylist()[player.getConfig().item].sources[0]); 
     1180                                document.location.href = jwplayer.html5.utils.getAbsolutePath(player.getPlaylist()[player.getConfig().item].levels[0]); 
    11811181                                return; 
    11821182                        } 
     
    16551655                        vid.autoplay = player._model.config.autoplay; 
    16561656                } 
    1657                 for (var sourceIndex in playlistItem.sources){ 
    1658                         var sourceModel = playlistItem.sources[sourceIndex]; 
     1657                for (var sourceIndex in playlistItem.levels){ 
     1658                        var sourceModel = playlistItem.levels[sourceIndex]; 
    16591659                        var source = div1.ownerDocument.createElement("source"); 
    16601660                        source.src = jwplayer.html5.utils.getAbsolutePath(sourceModel.file); 
     
    17061706                if (this.config.playlist && this.config.playlist.length > 0){ 
    17071707                        this.playlist = this.config.playlist; 
    1708                         delete this.config.playlist; 
    1709                 } else if (this.config.sources && this.config.sources.length > 0) { 
    1710                         this.playlist = [{"sources": this.config.sources}]; 
    1711                         delete this.config.sources; 
     1708                } else if (this.config.levels && this.config.levels.length > 0) { 
     1709                        this.playlist = [{"levels": this.config.levels}]; 
     1710                } else if (this.config.file){ 
     1711                        this.playlist = [{"levels": [{"file":this.config.file}]}]; 
    17121712                } 
    17131713                for (var index in _configurableStateVariables) { 
    17141714                        var configurableStateVariable = _configurableStateVariables[index]; 
    17151715                        this[configurableStateVariable] = this.config[configurableStateVariable]; 
     1716                } 
     1717                if (this.config.skin.length === 0){ 
     1718                        this.config.skin = "1.xml"; 
    17161719                } 
    17171720                return this; 
  • trunk/js/bin-debug/jwplayer.js

    r1217 r1218  
    121121 */ 
    122122jwplayer.utils.hasFlash = function() { 
    123         var nav = navigator; 
    124         return (typeof nav.plugins != "undefined" && typeof nav.plugins['Shockwave Flash'] != "undefined"); 
     123        return (typeof navigator.plugins != "undefined" && typeof navigator.plugins['Shockwave Flash'] != "undefined") || (typeof window.ActiveXObject != "undefined"); 
    125124};/** 
    126125 * Parser for the JW Player. 
     
    335334                var _stateListeners = {}; 
    336335                var _player = undefined; 
     336                var _playerReady = false; 
    337337                 
    338338                var _itemMeta = {}; 
     
    344344                        } 
    345345                        _player = player; 
    346                         for (var eventType in _listeners) { 
    347                                 this.addInternalListener(_player, eventType); 
    348                         } 
    349346                }; 
    350347                 
     
    359356                 
    360357                function stateCallback(state) { 
    361                         return function(newstate, oldstate) { 
     358                        return function(args) { 
     359                                var newstate = args['newstate'], 
     360                                        oldstate = args['oldstate']; 
    362361                                if (newstate == state) { 
    363362                                        var callbacks = _stateListeners[newstate]; 
     
    374373                 
    375374                this.addInternalListener = function(player, type) { 
    376                         player.addEventListener(type, 'function(dat) { jwplayer("'+this.id+'").dispatchEvent("'+type+'", dat); }'); 
     375                        player.jwAddEventListener(type, 'function(dat) { jwplayer("'+this.id+'").dispatchEvent("'+type+'", dat); }'); 
    377376                }; 
    378377                 
     
    380379                        if (!_listeners[type]) {  
    381380                                _listeners[type] = [];  
    382                                 if (_player) { 
     381                                if (_player && _playerReady) { 
    383382                                        this.addInternalListener(_player, type); 
    384383                                } 
     
    399398                 
    400399                this.playerReady = function(obj) { 
     400                        _playerReady = true; 
     401                        if (!_player) { 
     402                                this.setPlayer(document.getElementById(obj['id'])); 
     403                        } 
     404                         
     405                        for (var eventType in _listeners) { 
     406                                this.addInternalListener(_player, eventType); 
     407                        } 
     408 
    401409                        this.eventListener('jwplayerMediaMeta', function(data) { 
    402410                                jwplayer.utils.extend(_itemMeta, data.metadata); 
     
    446454                 
    447455                // Player Getters 
    448                 getBuffer: function() { return this.callInternal('getBuffer'); }, 
    449                 getDuration: function() { return this.callInternal('getDuration'); }, 
    450                 getFullscreen: function() { return this.callInternal('getFullscreen'); }, 
     456                getBuffer: function() { return this.callInternal('jwGetBuffer'); }, 
     457                getDuration: function() { return this.callInternal('jwGetDuration'); }, 
     458                getFullscreen: function() { return this.callInternal('jwGetFullscreen'); }, 
    451459                getHeight: function() { return this.container.height; }, 
    452                 getLockState: function() { return this.callInternal('getLockState'); }, 
     460                getLockState: function() { return this.callInternal('jwGetLockState'); }, 
    453461                getMeta: function() { return this.getItemMeta(); }, 
    454                 getMute: function() { return this.callInternal('getMute'); }, 
    455                 getPlaylist: function() { return this.callInternal('getPlaylist'); }, 
     462                getMute: function() { return this.callInternal('jwGetMute'); }, 
     463                getPlaylist: function() { return this.callInternal('jwGetPlaylist'); }, 
    456464                getPlaylistItem: function(item) { 
    457465                        if (item == undefined) item = 0; 
    458466                        return this.getPlaylist()[item];  
    459467                }, 
    460                 getPosition: function() { return this.callInternal('getPosition'); }, 
    461                 getState: function() { return this.callInternal('getState'); }, 
    462                 getVolume: function() { return this.callInternal('getVolume'); }, 
     468                getPosition: function() { return this.callInternal('jwGetPosition'); }, 
     469                getState: function() { return this.callInternal('jwGetState'); }, 
     470                getVolume: function() { return this.callInternal('jwGetVolume'); }, 
    463471                getWidth: function() { return this.container.width; }, 
    464472                 
    465473                // Player Public Methods 
    466                 setFullscreen: function(fullscreen) { this.callInternal("setFullscreen", fullscreen); return this;}, 
    467                 setMute: function(mute) { this.callInternal("mute", mute); return this; }, 
     474                setFullscreen: function(fullscreen) { this.callInternal("jwSetFullscreen", fullscreen); return this;}, 
     475                setMute: function(mute) { this.callInternal("jwMute", mute); return this; }, 
    468476                lock: function() { return this; }, 
    469477                unlock: function() { return this; }, 
    470                 load: function(toLoad) { this.callInternal("load", toLoad); return this; }, 
    471                 playlistItem: function(item) { this.callInternal("playlistItem", item); return this; }, 
    472                 playlistPrev: function() { this.callInternal("playlistPrev"); return this; }, 
    473                 playlistNext: function() { this.callInternal("playlistNext"); return this; }, 
     478                load: function(toLoad) { this.callInternal("jwLoad", toLoad); return this; }, 
     479                playlistItem: function(item) { this.callInternal("jwPlaylistItem", item); return this; }, 
     480                playlistPrev: function() { this.callInternal("jwPlaylistPrev"); return this; }, 
     481                playlistNext: function() { this.callInternal("jwPlaylistNext"); return this; }, 
    474482                resize: function(width, height) {  
    475483                        this.container.width = width;  
     
    495503                        case jwplayer.api.events.state.PLAYING: 
    496504                        case jwplayer.api.events.state.BUFFERING: 
    497                                 this.callInternal("pause"); 
     505                                this.callInternal("jwPause"); 
    498506                                break; 
    499507                        case jwplayer.api.events.state.PAUSED: 
    500                                 this.callInternal("play"); 
     508                                this.callInternal("jwPlay"); 
    501509                                break; 
    502510                        } 
    503511                        return this;  
    504512                }, 
    505                 stop: function() { this.callInternal("stop"); return this; },  
    506                 seek: function(position) { this.callInternal("seek", position); return this; }, 
    507                 setVolume: function(volume) { this.callInternal("volume", volume); return this; }, 
     513                stop: function() { this.callInternal("jwStop"); return this; },  
     514                seek: function(position) { this.callInternal("jwSeek", position); return this; }, 
     515                setVolume: function(volume) { this.callInternal("jwVolume", volume); return this; }, 
    508516                 
    509517                // Player Events 
     
    580588        }; 
    581589         
     590        jwplayer.api.destroyPlayer = function(playerId) { 
     591                var index = -1; 
     592                for(var p in _players) { 
     593                        if (_players[p].container.id == playerId) { 
     594                                index = p; 
     595                                continue; 
     596                        } 
     597                } 
     598                if (index >= 0) { 
     599                        var toDestroy = _players[index]; 
     600                        var replacement = document.createElement('div'); 
     601                        replacement.setAttribute('id', toDestroy.id); 
     602                        toDestroy.container.parentNode.replaceChild(replacement, toDestroy.container); 
     603                        _players.splice(index, 1); 
     604                } 
     605                 
     606                return null;             
     607        }; 
     608         
    582609        // Can't make this a read-only getter, thanks to IE incompatibility. 
    583610        jwplayer.getPlayers = function() {  
     
    626653                                                } 
    627654                                                var flashPlayer = jwplayer.embed.embedFlash(this.api.container, player, this.config); 
     655                                                this.api.container = flashPlayer; 
    628656                                                this.api.setPlayer(flashPlayer); 
    629657                                        } else { 
    630658                                                this.players.splice(0, 1); 
    631                                                 embedPlayer(); 
     659                                                this.embedPlayer(); 
    632660                                        } 
    633661                                        break; 
    634662                                case 'html5': 
    635                                         var html5player = jwplayer.embed.embedHTML5(this.api.container, player, this.config); 
    636                                         this.api.setPlayer(html5player); 
    637                                         //TODO: Remove this once HTML5 player calls playerReady() 
    638                                         this.api.playerReady({id:this.api.container.id}); 
     663                                        if (!jwplayer.utils.isIE()) { 
     664                                                var html5player = jwplayer.embed.embedHTML5(this.api.container, player, this.config); 
     665                                                this.api.setPlayer(html5player); 
     666                                                //TODO: Remove this once HTML5 player calls playerReady() 
     667                                                this.api.playerReady({id:this.api.container.id}); 
     668                                        } else { 
     669                                                this.players.splice(0, 1); 
     670                                                this.embedPlayer(); 
     671                                        } 
    639672                                        break; 
    640673                                } 
     674                        } else { 
     675                                this.api.container.innerHTML = "<p>No suitable players found</p>"; 
    641676                        } 
    642677                        return this.api; 
     
    680715        }; 
    681716         
    682         jwplayer.embed.embedFlash = function(container, player, options) { 
    683                 var params = jwplayer.utils.extend({}, jwplayer.embed.defaults, options); 
     717        jwplayer.embed.embedFlash = function(_container, _player, _options) { 
     718                var params = jwplayer.utils.extend({}, jwplayer.embed.defaults, _options); 
    684719                 
    685720                var width = params.width;  
     
    700735                        var html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +  
    701736                                'width="' + width + '" height="' + height + '" ' + 
    702                                 'id="' + container.id + '" name="' + container.id + 
     737                                'id="' + _container.id + '" name="' + _container.id + 
    703738                                '">'; 
    704                         html += '<param name="movie" value="' + player.src + '">'; 
     739                        html += '<param name="movie" value="' + _player.src + '">'; 
    705740                        html += '<param name="allowfullscreen" value="true">'; 
    706741                        html += '<param name="allowscriptaccess" value="always">'; 
    707742                        html += '<param name="flashvars" value="' + jwplayer.embed.jsonToFlashvars(params) +'">'; 
    708743                        html += '</object>'; 
    709                         container.outerHTML = html; 
    710                         return container; 
     744                        _container.outerHTML = html; 
     745                        return document.getElementById(_container.id); 
    711746                } else { 
    712747                        var obj = document.createElement('object'); 
    713748                        obj.setAttribute('type', 'application/x-shockwave-flash'); 
    714                         obj.setAttribute('data', player.src); 
     749                        obj.setAttribute('data', _player.src); 
    715750                        obj.setAttribute('width', width); 
    716751                        obj.setAttribute('height', height); 
    717                         obj.setAttribute('id', container.id); 
    718                         obj.setAttribute('name', container.id); 
     752                        obj.setAttribute('id', _container.id); 
     753                        obj.setAttribute('name', _container.id); 
    719754                        jwplayer.embed.appendAttribute(obj, 'allowfullscreen', 'true'); 
    720755                        jwplayer.embed.appendAttribute(obj, 'allowscriptaccess', 'always'); 
    721756                        jwplayer.embed.appendAttribute(obj, 'flashvars', jwplayer.embed.jsonToFlashvars(params)); 
    722                         container.parentNode.replaceChild(obj, container); 
     757                        _container.parentNode.replaceChild(obj, _container); 
    723758                        return obj; 
    724759                } 
     
    771806        }; 
    772807         
    773         jwplayer.api.PlayerAPI.prototype.setup = function(options, player) { 
     808        jwplayer.api.PlayerAPI.prototype.setup = function(options) { 
    774809                this.config = options; 
    775810                return (new jwplayer.embed.Embedder(this)).embedPlayer(); 
  • trunk/js/src/api/jwplayer.api.js

    r1206 r1218  
    4141                var _stateListeners = {}; 
    4242                var _player = undefined; 
     43                var _playerReady = false; 
    4344                 
    4445                var _itemMeta = {}; 
     
    5051                        } 
    5152                        _player = player; 
    52                         for (var eventType in _listeners) { 
    53                                 this.addInternalListener(_player, eventType); 
    54                         } 
    5553                }; 
    5654                 
     
    6563                 
    6664                function stateCallback(state) { 
    67                         return function(newstate, oldstate) { 
     65                        return function(args) { 
     66                                var newstate = args['newstate'], 
     67                                        oldstate = args['oldstate']; 
    6868                                if (newstate == state) { 
    6969                                        var callbacks = _stateListeners[newstate]; 
     
    8080                 
    8181                this.addInternalListener = function(player, type) { 
    82                         player.addEventListener(type, 'function(dat) { jwplayer("'+this.id+'").dispatchEvent("'+type+'", dat); }'); 
     82                        player.jwAddEventListener(type, 'function(dat) { jwplayer("'+this.id+'").dispatchEvent("'+type+'", dat); }'); 
    8383                }; 
    8484                 
     
    8686                        if (!_listeners[type]) {  
    8787                                _listeners[type] = [];  
    88                                 if (_player) { 
     88                                if (_player && _playerReady) { 
    8989                                        this.addInternalListener(_player, type); 
    9090                                } 
     
    105105                 
    106106                this.playerReady = function(obj) { 
     107                        _playerReady = true; 
     108                        if (!_player) { 
     109                                this.setPlayer(document.getElementById(obj['id'])); 
     110                        } 
     111                         
     112                        for (var eventType in _listeners) { 
     113                                this.addInternalListener(_player, eventType); 
     114                        } 
     115 
    107116                        this.eventListener('jwplayerMediaMeta', function(data) { 
    108117                                jwplayer.utils.extend(_itemMeta, data.metadata); 
     
    152161                 
    153162                // Player Getters 
    154                 getBuffer: function() { return this.callInternal('getBuffer'); }, 
    155                 getDuration: function() { return this.callInternal('getDuration'); }, 
    156                 getFullscreen: function() { return this.callInternal('getFullscreen'); }, 
     163                getBuffer: function() { return this.callInternal('jwGetBuffer'); }, 
     164                getDuration: function() { return this.callInternal('jwGetDuration'); }, 
     165                getFullscreen: function() { return this.callInternal('jwGetFullscreen'); }, 
    157166                getHeight: function() { return this.container.height; }, 
    158                 getLockState: function() { return this.callInternal('getLockState'); }, 
     167                getLockState: function() { return this.callInternal('jwGetLockState'); }, 
    159168                getMeta: function() { return this.getItemMeta(); }, 
    160                 getMute: function() { return this.callInternal('getMute'); }, 
    161                 getPlaylist: function() { return this.callInternal('getPlaylist'); }, 
     169                getMute: function() { return this.callInternal('jwGetMute'); }, 
     170                getPlaylist: function() { return this.callInternal('jwGetPlaylist'); }, 
    162171                getPlaylistItem: function(item) { 
    163172                        if (item == undefined) item = 0; 
    164173                        return this.getPlaylist()[item];  
    165174                }, 
    166                 getPosition: function() { return this.callInternal('getPosition'); }, 
    167                 getState: function() { return this.callInternal('getState'); }, 
    168                 getVolume: function() { return this.callInternal('getVolume'); }, 
     175                getPosition: function() { return this.callInternal('jwGetPosition'); }, 
     176                getState: function() { return this.callInternal('jwGetState'); }, 
     177                getVolume: function() { return this.callInternal('jwGetVolume'); }, 
    169178                getWidth: function() { return this.container.width; }, 
    170179                 
    171180                // Player Public Methods 
    172                 setFullscreen: function(fullscreen) { this.callInternal("setFullscreen", fullscreen); return this;}, 
    173                 setMute: function(mute) { this.callInternal("mute", mute); return this; }, 
     181                setFullscreen: function(fullscreen) { this.callInternal("jwSetFullscreen", fullscreen); return this;}, 
     182                setMute: function(mute) { this.callInternal("jwMute", mute); return this; }, 
    174183                lock: function() { return this; }, 
    175184                unlock: function() { return this; }, 
    176                 load: function(toLoad) { this.callInternal("load", toLoad); return this; }, 
    177                 playlistItem: function(item) { this.callInternal("playlistItem", item); return this; }, 
    178                 playlistPrev: function() { this.callInternal("playlistPrev"); return this; }, 
    179                 playlistNext: function() { this.callInternal("playlistNext"); return this; }, 
     185                load: function(toLoad) { this.callInternal("jwLoad", toLoad); return this; }, 
     186                playlistItem: function(item) { this.callInternal("jwPlaylistItem", item); return this; }, 
     187                playlistPrev: function() { this.callInternal("jwPlaylistPrev"); return this; }, 
     188                playlistNext: function() { this.callInternal("jwPlaylistNext"); return this; }, 
    180189                resize: function(width, height) {  
    181190                        this.container.width = width;  
     
    201210                        case jwplayer.api.events.state.PLAYING: 
    202211                        case jwplayer.api.events.state.BUFFERING: 
    203                                 this.callInternal("pause"); 
     212                                this.callInternal("jwPause"); 
    204213                                break; 
    205214                        case jwplayer.api.events.state.PAUSED: 
    206                                 this.callInternal("play"); 
     215                                this.callInternal("jwPlay"); 
    207216                                break; 
    208217                        } 
    209218                        return this;  
    210219                }, 
    211                 stop: function() { this.callInternal("stop"); return this; },  
    212                 seek: function(position) { this.callInternal("seek", position); return this; }, 
    213                 setVolume: function(volume) { this.callInternal("volume", volume); return this; }, 
     220                stop: function() { this.callInternal("jwStop"); return this; },  
     221                seek: function(position) { this.callInternal("jwSeek", position); return this; }, 
     222                setVolume: function(volume) { this.callInternal("jwVolume", volume); return this; }, 
    214223                 
    215224                // Player Events 
     
    286295        }; 
    287296         
     297        jwplayer.api.destroyPlayer = function(playerId) { 
     298                var index = -1; 
     299                for(var p in _players) { 
     300                        if (_players[p].container.id == playerId) { 
     301                                index = p; 
     302                                continue; 
     303                        } 
     304                } 
     305                if (index >= 0) { 
     306                        var toDestroy = _players[index]; 
     307                        var replacement = document.createElement('div'); 
     308                        replacement.setAttribute('id', toDestroy.id); 
     309                        toDestroy.container.parentNode.replaceChild(replacement, toDestroy.container); 
     310                        _players.splice(index, 1); 
     311                } 
     312                 
     313                return null;             
     314        }; 
     315         
    288316        // Can't make this a read-only getter, thanks to IE incompatibility. 
    289317        jwplayer.getPlayers = function() {  
  • trunk/js/src/embed/jwplayer.embed.js

    r1206 r1218  
    2828                                                } 
    2929                                                var flashPlayer = jwplayer.embed.embedFlash(this.api.container, player, this.config); 
     30                                                this.api.container = flashPlayer; 
    3031                                                this.api.setPlayer(flashPlayer); 
    3132                                        } else { 
    3233                                                this.players.splice(0, 1); 
    33                                                 embedPlayer(); 
     34                                                this.embedPlayer(); 
    3435                                        } 
    3536                                        break; 
    3637                                case 'html5': 
    37                                         var html5player = jwplayer.embed.embedHTML5(this.api.container, player, this.config); 
    38                                         this.api.setPlayer(html5player); 
    39                                         //TODO: Remove this once HTML5 player calls playerReady() 
    40                                         this.api.playerReady({id:this.api.container.id}); 
     38                                        if (!jwplayer.utils.isIE()) { 
     39                                                var html5player = jwplayer.embed.embedHTML5(this.api.container, player, this.config); 
     40                                                this.api.setPlayer(html5player); 
     41                                                //TODO: Remove this once HTML5 player calls playerReady() 
     42                                                this.api.playerReady({id:this.api.container.id}); 
     43                                        } else { 
     44                                                this.players.splice(0, 1); 
     45                                                this.embedPlayer(); 
     46                                        } 
    4147                                        break; 
    4248                                } 
     49                        } else { 
     50                                this.api.container.innerHTML = "<p>No suitable players found</p>"; 
    4351                        } 
    4452                        return this.api; 
     
    8290        }; 
    8391         
    84         jwplayer.embed.embedFlash = function(container, player, options) { 
    85                 var params = jwplayer.utils.extend({}, jwplayer.embed.defaults, options); 
     92        jwplayer.embed.embedFlash = function(_container, _player, _options) { 
     93                var params = jwplayer.utils.extend({}, jwplayer.embed.defaults, _options); 
    8694                 
    8795                var width = params.width;  
     
    102110                        var html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ' +  
    103111                                'width="' + width + '" height="' + height + '" ' + 
    104                                 'id="' + container.id + '" name="' + container.id + 
     112                                'id="' + _container.id + '" name="' + _container.id + 
    105113                                '">'; 
    106                         html += '<param name="movie" value="' + player.src + '">'; 
     114                        html += '<param name="movie" value="' + _player.src + '">'; 
    107115                        html += '<param name="allowfullscreen" value="true">'; 
    108116                        html += '<param name="allowscriptaccess" value="always">'; 
    109117                        html += '<param name="flashvars" value="' + jwplayer.embed.jsonToFlashvars(params) +'">'; 
    110118                        html += '</object>'; 
    111                         container.outerHTML = html; 
    112                         return container; 
     119                        _container.outerHTML = html; 
     120                        return document.getElementById(_container.id); 
    113121                } else { 
    114122                        var obj = document.createElement('object'); 
    115123                        obj.setAttribute('type', 'application/x-shockwave-flash'); 
    116                         obj.setAttribute('data', player.src); 
     124                        obj.setAttribute('data', _player.src); 
    117125                        obj.setAttribute('width', width); 
    118126                        obj.setAttribute('height', height); 
    119                         obj.setAttribute('id', container.id); 
    120                         obj.setAttribute('name', container.id); 
     127                        obj.setAttribute('id', _container.id); 
     128                        obj.setAttribute('name', _container.id); 
    121129                        jwplayer.embed.appendAttribute(obj, 'allowfullscreen', 'true'); 
    122130                        jwplayer.embed.appendAttribute(obj, 'allowscriptaccess', 'always'); 
    123131                        jwplayer.embed.appendAttribute(obj, 'flashvars', jwplayer.embed.jsonToFlashvars(params)); 
    124                         container.parentNode.replaceChild(obj, container); 
     132                        _container.parentNode.replaceChild(obj, _container); 
    125133                        return obj; 
    126134                } 
     
    173181        }; 
    174182         
    175         jwplayer.api.PlayerAPI.prototype.setup = function(options, player) { 
     183        jwplayer.api.PlayerAPI.prototype.setup = function(options) { 
    176184                this.config = options; 
    177185                return (new jwplayer.embed.Embedder(this)).embedPlayer(); 
  • trunk/js/src/utils/jwplayer.utils.js

    r1217 r1218  
    117117 */ 
    118118jwplayer.utils.hasFlash = function() { 
    119         var nav = navigator; 
    120         return (typeof nav.plugins != "undefined" && typeof nav.plugins['Shockwave Flash'] != "undefined"); 
     119        return (typeof navigator.plugins != "undefined" && typeof navigator.plugins['Shockwave Flash'] != "undefined") || (typeof window.ActiveXObject != "undefined"); 
    121120}; 
  • trunk/js/test/index.php

    r1208 r1218  
    101101                prefilled = {plugins:'',player:'',skin:''}; 
    102102                var swf = settings.players[$("#players").val()][0]['src']; 
    103                 var xml = swf.substr(0,swf.length-4) + '.xml'; 
    104                 parsePlayerXML(xml); 
     103                if (swf) { 
     104                        var xml = swf.substr(0,swf.length-4) + '.xml'; 
     105                        parsePlayerXML(xml); 
     106            } else { 
     107                parsePlayerXML("jwplayer.html5.xml"); 
     108            } 
    105109                var str = $("#plugins").val(); 
    106110                if(str != null) { 
     
    280284 
    281285        $('#preview').css('height',vrs['height']); 
    282         $('#preview').html('<div id="container"></div>'); 
     286        if ($('#container').length) { 
     287                // This is necessary for IE when calling setup on top of an existing flash player 
     288//              jwplayer.api.destroyPlayer('container'); 
     289        } else { 
     290                $('#preview').html('<div id="container"></div>'); 
     291        } 
    283292 
    284293        for (var v in vrs){ 
     
    443452 
    444453<?php 
    445   $selectedScript = 'swfobject'; 
     454  $selectedScript = 'jwembed'; 
    446455  if (isset($_GET['scripts'])){ 
    447456        $selectedScript = $_GET['scripts']; 
  • trunk/js/test/settings.js

    r1206 r1218  
    1515        /** Player versions to test. **/ 
    1616        "players": { 
    17                 "flash-5.3":[{"type":"flash","src":"players/player-5.3.swf"}], 
    18                 "flash-5.2":[{"type":"flash","src":"players/player-5.2.swf"}], 
    19                 "flash-5.1":[{"type":"flash","src":"players/player-5.1.swf"}], 
    20                 "flash-5.0":[{"type":"flash","src":"players/player-5.0.swf"}], 
    21                 "flash-4.7":[{"type":"flash","src":"players/player-4.7.swf"}], 
    22                 "flash-4.6":[{"type":"flash","src":"players/player-4.6.swf"}], 
    23                 "flash-4.5":[{"type":"flash","src":"players/player-4.5.swf"}], 
    24                 "flash-4.4":[{"type":"flash","src":"players/player-4.4.swf"}], 
    25                 "flash-4.3":[{"type":"flash","src":"players/player-4.3.swf"}], 
    26                 "flash-4.2":[{"type":"flash","src":"players/player-4.2.swf"}], 
    27                 "flash-4.1":[{"type":"flash","src":"players/player-4.1.swf"}] 
     17                "flash-html5-fallback":[{"type":"flash","src":"player-5.3.swf"},{"type":"html5"}], 
     18                "html5-flash-fallback":[{"type":"html5"},{"type":"flash","src":"player-5.3.swf"}], 
     19                "flash-only":[{"type":"flash","src":"player-5.3.swf"}], 
     20                "html5-only":[{"type":"html5"}] 
    2821        }, 
    2922        /** Available plugins to test. **/ 
     
    6053                " ": {}, 
    6154                "FLV video": { 
    62                         "file":"../files/bunny.flv", 
     55                        "file":"files/bunny.flv", 
    6356                        "image":"files/bunny.jpg", 
    6457                        "height":240, 
     
    6760                }, 
    6861                "MP4 video": { 
    69                         "file":"../files/bunny.mp4", 
     62                        "file":"files/bunny.mp4", 
    7063                        "image":"files/bunny.jpg", 
    7164                        "height":240, 
     
    7871                }, 
    7972                "AAC audio":{ 
    80                         "file":"../files/bunny.m4a", 
     73                        "file":"files/bunny.m4a", 
    8174                        "image":"files/bunny.jpg", 
    8275                        "height":240, 
     
    199192                " ": {}, 
    200193                "Agegate plugin": { 
    201                         "file":"../files/corrie.flv", 
     194                        "file":"files/corrie.flv", 
    202195                        "height":240, 
    203196                        "width":500, 
     
    206199                }, 
    207200                "Audiodescription and captions plugins": { 
    208                         "file":"../files/corrie.flv", 
     201                        "file":"files/corrie.flv", 
    209202                        "height":240, 
    210203                        "width":500, 
     
    228221                }, 
    229222                "HD plugin": { 
    230                         "file":"../files/bunny.flv", 
     223                        "file":"files/bunny.flv", 
    231224                        "height":240, 
    232225                        "width":500, 
    233226                        "plugins":"hd", 
    234227                        "dock":"true", 
    235                         "hd.file":"../files/bunny.mp4" 
     228                        "hd.file":"files/bunny.mp4" 
    236229                }, 
    237230                "Searchbar plugin": { 
     
    245238                "Sharing plugin": { 
    246239                        "dock":true, 
    247                         "file":"../files/bunny.flv", 
     240                        "file":"files/bunny.flv", 
    248241                        "height":260, 
    249242                        "width":460, 
Note: See TracChangeset for help on using the changeset viewer.