How can i change video source externally by js? for example, videourl.no-iosand and videourl.ios.

  • Here is the xml code of video plugin, but i want to change the video url from js, is there any solution?
    It seems that i can use the " krpano Javascript-Interface object" set(variable,value) method, but what is the varible?


    <plugin name="video"
    ▽ url.flash="%SWFPATH%/plugins/videoplayer.swf"
    url.html5="%SWFPATH%/plugins/videoplayer.js"

    posterurl.ios="../resource/VRm_low.jpg"
    videourl.ios="../resource/VRm_low.mp4|VRm_low.webm"


    posterurl.no-ios="../resource/VRm_high.jpg"
    videourl.no-ios="../resource/VRm_high.mp4|VRm_high.webm"

    pausedonstart="true"
    loop="true"
    enabled="false"
    zorder="0"
    align="center" ox="0" oy="0"

    width.no-panovideosupport="100%"
    height.no-panovideosupport="prop"

    onloaded="videointerface_setup_interface(get(name)); setup_video_controls();"
    onvideoready="videointerface_videoready();"
    />

  • Hi,

    that's static xml code, for dynamic code you should use the playvideo() action:
    https://krpano.com/plugins/videoplayer/#playvideo

    and the call() interface:
    https://krpano.com/docu/js/#top

    e.g.

    Code
    if(...is iOS...)
      krpano.call("plugin[video].playvideo('video_low.mp4', 'poster_low.jpg');");
    else
      krpano.call("plugin[video].playvideo('video_hi.mp4', 'poster_hi.jpg');");

    Best regards,
    Klaus

  • sorry, the video did not change , what is the problem? is my video path wrong? but i have tried all kinds of path, none worked.

    html path: "."
    video path: "./resource/VRm_high.mp4";
    xml path: "./xml/video.xml"

    <script>
    function churl(){
    var krpano =document.getElementById("krpanoSWFObject");
    krpano.call("plugin[video].playvideo('../resource/VRm_high.mp4')");
    //krpano.call("plugin[video].playvideo('resource/VRm_high.mp4')");
    //krpano.call("plugin[video].playvideo('VRm_high.mp4')");

    }
    </script>

  • First of all, thank you all for giving me methods and advice. Now the problem can be solved by two means:

    Firstly, use krpano object call function. when the page is loaded, call the function churl() to change the video source

    Code
    <script>     function churl(){        var krpano =document.getElementById("krpanoSWFObject");        krpano.call("plugin[video].playvideo('resource/VRm_high.mp4')");        }</script>




    Secondly, when the krpano is embedded some parameters can be set to change the xml file. REFERENCE: https://krpano.com/docu/html/#vars


    And the second method can truly solve my problem.

  • Hi,

    that's static xml code, for dynamic code you should use the playvideo() action:
    https://krpano.com/plugins/videoplayer/#playvideo

    and the call() interface:
    https://krpano.com/docu/js/#top

    e.g.

    Code
    if(...is iOS...)
      krpano.call("plugin[video].playvideo('video_low.mp4', 'poster_low.jpg');");
    else
      krpano.call("plugin[video].playvideo('video_hi.mp4', 'poster_hi.jpg');");

    Best regards,
    Klaus

    This `if(...is iOS...)` is a little confusing. What's the code to actually detect ios/firefox with krpano?

    Wouldn't it be better to just set the plugin like so:

    Code
    krpano.call("set(hotspot[panoThumbnail" + data[d].id + "].onclick, set( plugin[video].videourl.no-ios,/panorama/"+ data[d].id +"/video-1920x960.mp4|/panorama/"+ data[d].id +"/video-1920x960.webm ); set( plugin[video].videourl.ios,/panorama/"+ data[d].id +"/video-1344x672.mp4|/panorama/"+ data[d].id +"/video-iphone-sound.mp3 ); changepano( loadscene(video_scene, null, MERGE|KEEPVIEW|KEEPMOVING, BLEND(1)); ););");


    The device/browser detection is already integrated this way. However, I'm finding that my suggested method does not work

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!