Skip to main content
August 25, 2012
Answered

Disable autoplay or switch divs?

  • August 25, 2012
  • 1 reply
  • 1336 views

If this is in the wrong section please forgive my noobishness and feel free to move it where it needs to be.

I am currently working on a website and the client has asked me to include a swf animation on his new website. It was not made by me, nor do I have the .fla file.

While it is easy enough to display the file, the problem is he has asked me to disable it from autoplaying.

I was wondering if this was at all possible by editing the Javascript file? I was wondering if it was possible to call the "playagain" div first, leaving the "webvideo" div hidden untill the button is clicked.

Please could anyone tell me if any of this is possible. I do not know javascript, so I am really at a loss. Thank you.

Here is the javascript I am calling in to my html page..

if (typeof video == 'undefined') {

          video = new Object();

}

video.params = {

          width:280,

          height:360,

          left:"6px",

          right:"auto",

          autoplay:"false",

          top:"auto",

          bottom:"0px",

          vidlink:"",

          openin:"_blank",

          flv:"video",

          xmlPath:"data1.xml"

};

video.drawVideo= function(){

          var markUp = '';

          markUp += '<style type="text/css">';

          markUp += '#webvideo {position:fixed;width:'+video.params.width+'px;height:'+video.params.height+'px;left:'+video.params.left+';right:'+video.params.right+';top:'+video.params.top+';bottom:'+video.params.bottom+';z-index:500;}';

          markUp += '#playagain {position:fixed;left:1px;right:auto;top:auto;bottom:2px;z-index:2;visibility:hidden}';

          markUp += '</style>';

          markUp += '<div id="webvideo">';

          markUp += '  <object id="objvideo" style="outline:none;" type="application/x-shockwave-flash" width="280" height="360" wmode="transparent" data="videopresenter.swf">';

          markUp += '    <param name="movie" value="videopresenter.swf" />';

          markUp += '    <param name="quality" value="high" />';

          markUp += '    <param name="flashvars" value="vurl='+video.params.flv+'.flv&vwidth='+video.params.width+'&vheight='+video.params.height+'&vlink='+video.params.vidlink+'&openin='+video.params.openin+'&xmlPath='+video.params.xmlPath+'" />';

          markUp += '    <param name="wmode" value="transparent" />';

          markUp += '    <param name="allowscriptaccess" value="always" />';

          markUp += '    <param name="swfversion" value="9.0.45.0" />';

          markUp += '  </object>';

          markUp += '</div>';

          markUp += '<div id="playagain">';

          markUp += '<a href="javascript:showDiv()"><img src="videopresenter/images/playBtn.gif" width="82" height="32" border="0"/></a>';

          markUp += '</div>';

          document.write(markUp);

}

function thisMovie(movieName) {

    if (navigator.appName.indexOf("Microsoft") != -1) {

        return window[movieName]

    }

    else {

        return document[movieName]

    }

}

function closeDiv(){

          document.getElementById('webvideo').style.visibility = 'hidden';

}

function showPlayAgainButton(){

          document.getElementById('webvideo').style.zIndex='-100';

          document.getElementById('playagain').style.visibility = 'visible';

}

function showDiv(){

          thisMovie("objvideo").showPlayer();

          document.getElementById('webvideo').style.zIndex='1';

          document.getElementById('webvideo').style.visibility = 'visible';

          document.getElementById('playagain').style.visibility = 'hidden';

}

function lightsOff () {

            $("div#mainBody").animate({opacity: 0.3},500);

            return false;

}

function lightsOn() {

               $("div#mainBody").animate({opacity: 100},500);

               return false;

}

video.drawVideo();

This topic has been closed for replies.
Correct answer

Thank You, but I'm afraid that didnt stop the video playing. I think because It had built in controls.

I managed to figure it out though.. this is what I came up with for anyone interested. As I said I am new to flash, so maybe someone could tell me if there is there anything messy about it?

Thanks

if (typeof video == 'undefined') {

          video = new Object();

}

video.params = {

          width:280,

          height:360,

          left:"6px",

          right:"auto",

          top:"auto",

          bottom:"0px",

          vidlink:"",

          openin:"_blank",

          flv:"video",

          xmlPath:"data1.xml"

};

video.drawVideo= function(){

          var markUp = '';

          markUp += '<style type="text/css">';

          markUp += '#webvideo {position:fixed;width:'+video.params.width+'px;height:'+video.params.height+'px;left:'+video.params.left+';right:'+video.params.right+';top:'+video.params.top+';bottom:'+video.params.bottom+';z-index:-100;display:none}';

          markUp += '#playagain {position:fixed;left:1px;right:auto;top:auto;bottom:2px;z-index:2;}';

          markUp += '</style>';

          markUp += '<div id="webvideo">';

          markUp += '  <object id="objvideo" style="outline:none;" type="application/x-shockwave-flash" width="280" height="360" wmode="transparent" data="videopresenter.swf">';

          markUp += '    <param name="movie" value="videopresenter.swf" />';

          markUp += '    <param name="quality" value="high" />';

          markUp += '    <param name="flashvars" value="vurl='+video.params.flv+'.flv&vwidth='+video.params.width+'&vheight='+video.params.height+'&vlink='+video.params.vidlink+'&openin='+video.params.openin+'&xmlPath='+video.params.xmlPath+'" />';

          markUp += '    <param name="wmode" value="transparent" />';

          markUp += '    <param name="allowscriptaccess" value="always" />';

          markUp += '    <param name="swfversion" value="9.0.45.0" />';

          markUp += '  </object>';

          markUp += '</div>';

          markUp += '<div id="playagain">';

          markUp += '<a href="javascript:showDiv()"><img src="videopresenter/images/playBtn.gif" width="82" height="32" border="0"/></a>';

          markUp += '</div>';

          document.write(markUp);

}

function thisMovie(movieName) {

    if (navigator.appName.indexOf("Microsoft") != -1) {

        return window[movieName]

    }

    else {

        return document[movieName]

    }

}

function closeDiv(){

          document.getElementById('webvideo').style.visibility = 'hidden';

}

function showPlayAgainButton(){

          document.getElementById('webvideo').style.zIndex='-100';

          document.getElementById('playagain').style.visibility = 'visible';

}

function showDiv(){

          document.getElementById('webvideo').style.display='inline';

          document.getElementById('webvideo').style.zIndex='1';

          document.getElementById('webvideo').style.visibility = 'visible';

          document.getElementById('playagain').style.visibility = 'hidden';

          thisMovie("objvideo").showPlayer();

 

}

function lightsOff () {

            $("div#mainBody").animate({opacity: 0.3},500);

            return false;

}

function lightsOn() {

               $("div#mainBody").animate({opacity: 100},500);

               return false;

}

video.drawVideo();

1 reply

kglad
Community Expert
Community Expert
August 25, 2012

try:

if (typeof video == 'undefined') {

          video = new Object();

}

video.params = {

          width:280,

          height:360,

          left:"6px",

          right:"auto",

          autoplay:"false",

          top:"auto",

          bottom:"0px",

          vidlink:"",

          openin:"_blank",

          flv:"video",

          xmlPath:"data1.xml"

};

video.drawVideo= function(){

          var markUp = '';

          markUp += '<style type="text/css">';

          markUp += '#webvideo {position:fixed;width:'+video.params.width+'px;height:'+video.params. height+'px;left:'+video.params.left+';right:'+video.params.right+';top :'+video.params.top+';bottom:'+video.params.bottom+';z-index:500;}';

          markUp += '#playagain {position:fixed;left:1px;right:auto;top:auto;bottom:2px;z-index:2;vis ibility:hidden}';

          markUp += '</style>';

          markUp += '<div id="webvideo">';

          markUp += '  <object id="objvideo" style="outline:none;" type="application/x-shockwave-flash" width="280" height="360" wmode="transparent" data="videopresenter.swf">';

          markUp += '    <param name="movie" value="videopresenter.swf" />';

          markUp += '    <param name="quality" value="high" />';

          markUp += '    <param name="flashvars" value="vurl='+video.params.flv+'.flv&vwidth='+video.params.width+ '&vheight='+video.params.height+'&vlink='+video.params.vidlink +'&openin='+video.params.openin+'&xmlPath='+video.params.xmlPa th+'" />';

          markUp += '    <param name="wmode" value="transparent" />';

          markUp += '    <param name="allowscriptaccess" value="always" />';

          markUp += '    <param name="swfversion" value="9.0.45.0" />';

          markUp += '    <param name="play" value="false" />';

          markUp += '  </object>';

          markUp += '</div>';

          markUp += '<div id="playagain">';

          markUp += '<a href="javascript:showDiv()"><img src="videopresenter/images/playBtn.gif" width="82" height="32" border="0"/></a>';

          markUp += '</div>';

          document.write(markUp);

}

function thisMovie(movieName) {

    if (navigator.appName.indexOf("Microsoft") != -1) {

        return window[movieName]

    }

    else {

        return document[movieName]

    }

}

function closeDiv(){

          document.getElementById('webvideo').style.visibility = 'hidden';

}

function showPlayAgainButton(){

          document.getElementById('webvideo').style.zIndex='-100';

          document.getElementById('playagain').style.visibility = 'visible';

}

function showDiv(){

          thisMovie("objvideo").showPlayer();

          document.getElementById('webvideo').style.zIndex='1';

          document.getElementById('webvideo').style.visibility = 'visible';

          document.getElementById('playagain').style.visibility = 'hidden';

}

function lightsOff () {

            $("div#mainBody").animate({opacity: 0.3},500);

            return false;

}

function lightsOn() {

               $("div#mainBody").animate({opacity: 100},500);

               return false;

}

video.drawVideo();

Correct answer
August 26, 2012

Thank You, but I'm afraid that didnt stop the video playing. I think because It had built in controls.

I managed to figure it out though.. this is what I came up with for anyone interested. As I said I am new to flash, so maybe someone could tell me if there is there anything messy about it?

Thanks

if (typeof video == 'undefined') {

          video = new Object();

}

video.params = {

          width:280,

          height:360,

          left:"6px",

          right:"auto",

          top:"auto",

          bottom:"0px",

          vidlink:"",

          openin:"_blank",

          flv:"video",

          xmlPath:"data1.xml"

};

video.drawVideo= function(){

          var markUp = '';

          markUp += '<style type="text/css">';

          markUp += '#webvideo {position:fixed;width:'+video.params.width+'px;height:'+video.params.height+'px;left:'+video.params.left+';right:'+video.params.right+';top:'+video.params.top+';bottom:'+video.params.bottom+';z-index:-100;display:none}';

          markUp += '#playagain {position:fixed;left:1px;right:auto;top:auto;bottom:2px;z-index:2;}';

          markUp += '</style>';

          markUp += '<div id="webvideo">';

          markUp += '  <object id="objvideo" style="outline:none;" type="application/x-shockwave-flash" width="280" height="360" wmode="transparent" data="videopresenter.swf">';

          markUp += '    <param name="movie" value="videopresenter.swf" />';

          markUp += '    <param name="quality" value="high" />';

          markUp += '    <param name="flashvars" value="vurl='+video.params.flv+'.flv&vwidth='+video.params.width+'&vheight='+video.params.height+'&vlink='+video.params.vidlink+'&openin='+video.params.openin+'&xmlPath='+video.params.xmlPath+'" />';

          markUp += '    <param name="wmode" value="transparent" />';

          markUp += '    <param name="allowscriptaccess" value="always" />';

          markUp += '    <param name="swfversion" value="9.0.45.0" />';

          markUp += '  </object>';

          markUp += '</div>';

          markUp += '<div id="playagain">';

          markUp += '<a href="javascript:showDiv()"><img src="videopresenter/images/playBtn.gif" width="82" height="32" border="0"/></a>';

          markUp += '</div>';

          document.write(markUp);

}

function thisMovie(movieName) {

    if (navigator.appName.indexOf("Microsoft") != -1) {

        return window[movieName]

    }

    else {

        return document[movieName]

    }

}

function closeDiv(){

          document.getElementById('webvideo').style.visibility = 'hidden';

}

function showPlayAgainButton(){

          document.getElementById('webvideo').style.zIndex='-100';

          document.getElementById('playagain').style.visibility = 'visible';

}

function showDiv(){

          document.getElementById('webvideo').style.display='inline';

          document.getElementById('webvideo').style.zIndex='1';

          document.getElementById('webvideo').style.visibility = 'visible';

          document.getElementById('playagain').style.visibility = 'hidden';

          thisMovie("objvideo").showPlayer();

 

}

function lightsOff () {

            $("div#mainBody").animate({opacity: 0.3},500);

            return false;

}

function lightsOn() {

               $("div#mainBody").animate({opacity: 100},500);

               return false;

}

video.drawVideo();