Plugin Actions via External Javascript Interface

  • Hi all

    I'm trying to make a video play on button click but am having problems calling plugin actions via external javascript with the following code. Any ideas why this isn't working?

    Code
    <li  class="mainbutton"><a href="#" onclick="playvideo();">WATCH VIDEO</a></li>
    
    
    <script>
    embedpano({swf:"krpano.swf", xml:"video.xml", target:"pano", id:"krpanoSWFObject", html5:(document.domain ? "prefer" : "auto"), passQueryParameters:true}); 
    var krpano = document.getElementById("krpanoSWFObject");
    function playvideo() { krpano.call("plugin[videointerface].togglepause();");			}
    </script>
  • Hi,

    the problem in your code is that it takes some time until the krpano viewer is loaded, embedded any ready.

    That means the 'getElementById' call directly after the 'embedpano' call will not work in the most cases.

    Either do the 'getElementById' directly in the playvideo() function - or better - use the 'onready' callback:
    https://krpano.com/docu/html/#onready

    e.g.

    Best regards,
    Klaus

  • Thanks for the reply Klaus

    I've tried your method using the onready callback and it seems to work sporadically which is strange (I'm using the testing server to view the html file).

    Is there any way to ensure that the krpano viewer is loaded before the page is shown? Can I load the krpano viewer in the html header?

    Kind regards and Merry Christmas!

    Edward

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!