- external interface and swfobject.js issue
- $(function(){
- //the video player shouldn't be built until the user presses the div with 'video-btn' class
- $('.video-btn').click(function(){
- var videoplayer = new VideoPlayer();
- videoplayer.addVideoPlayer();
- //external interface function
- videoplayer.player.loadVideo();
- });
- });
- //inside of VideoPlayer object definition
- this.addVideoPlayer = function(){
- var that = this;
- $('body').append('<div id="no-flash"></div>');
- //uses swfobject.js to replace the div i just appended with the flash object
- //This works fine. the flash object replaces the div as intended
- that.embedFlashObject();
- //that.player is (supposed to be) a reference to flash object
- that.player = that.getFlashObject();
- };
- this.embedFlashObject = function(){
- var that = this;
- //set up all the variables to pass to swfobject.embedSWF
- //this method removes my div and replaces it with an object element that contains the swf file
- //the object tag gets an id which is specified. Let's assume it's 'vp'
- swfobject.embedSWF(swfFile, 'no-flash', width, hieght, '9.0.0', ... );
- };
- this.getFlashObject = function(){
- var that = this;
- //this method returns the flash object to make external interface calls on
- //this the method prescribed by swfobject api
- var videoObj = swfobject.getObjectById('vp');
- if(typeOf videoObj == 'undefined')
- {
- //check if useragent string is IE
- var isIE = navigator.userAgent.match(/MSIE/i);
- videoObj = isIE ? window['vp'] : document['vp'];
- }
- return videoObj;
- };
- //inside of VideoPlayer object definition
- this.addVideoPlayer = function(){
- var that = this;
- if (swfobject.hasFlashPlayerVersion("9")){
- $('body').append('<div id="no-flash"></div>');
- //For legibility
- var swfdata = {
- data: swfFile,
- width: width,
- height: height
- };
- var params = { bgcolor: color };
- var id = 'no-flash';
- that.player = swfobject.createSWF(swfdata, params, id);
- }
- };
- //inside of VideoPlayer object definition
- this.addVideoPlayer = function(){
- var that = this;
- if (swfobject.hasFlashPlayerVersion("9")){
- $('body').append('<div id="no-flash"></div>');
- that.player = swfobject.createSWF({data: swfFile, width: width, height: height}, {bgcolor: color}, 'no-flash');
- }
- };
- swfobject.embedSWF("/Flash/Player.swf", "flash", "100%", "100%", swfVersionStr, xiSwfUrlStr, flashvars, params, attributes, function (e) {
- document.getElementById("flash").loadMedia();
- });
- var videoObj = swfobject.getObjectById('vp');
- if(typeOf videoObj == 'undefined')
- {
- //check if useragent string is IE
- var isIE = navigator.userAgent.match(/MSIE/i);
- videoObj = isIE ? window['vp'] : document['vp'];
- }
- return videoObj;
- if(typeOf videoObj == 'undefined')
- {
- //check if useragent string is IE
- var isIE = navigator.userAgent.match(/MSIE/i);
- videoObj = isIE ? window['vp'] : document['vp'];
- }