Adding Video-Hotspots via js

  • I'm trying to add Video-Hotspots via js like I do for normal hotspots:


    Code
    krpano.call('addhotspot(myname)');krpano.call('set(hotspot[myname].ath,' + hotspot.position.x + ')');krpano.call('set(hotspot[myname].atv,' + hotspot.position.y + ')');       krpano.call('set(hotspot[myname].loadedurl, krpano/plugins/videoplayer.js)');krpano.call('set(hotspot[myname].loadingurl, krpano/plugins/videoplayer.js)');krpano.call('set(hotspot[myname].url.html5, krpano/plugins/videoplayer.js)');krpano.call('set(hotspot[myname].videourl, content/video.mp4)');krpano.call('set(hotspot[myname].posterurl, content/poster.jpg)');krpano.call('set(hotspot[myname].distorted, true)');krpano.call('set(hotspot[myname].scale, 0.5)');krpano.call('set(hotspot[myname].rx, 0)');krpano.call('set(hotspot[myname].ry, 0)');krpano.call('set(hotspot[myname].rz, 0)');krpano.call('set(hotspot[myname].pausedonstart, false)');krpano.call('set(hotspot[myname].loop, false)');krpano.call('set(hotspot[myname].volume, 1)');krpano.call('set(hotspot[myname].directionalsound, true)');krpano.call('set(hotspot[myname].range, 90.0)');krpano.call('set(hotspot[myname].rangefalloff, 1)');krpano.call('set(hotspot[myname].outofrangevolume, 0)');krpano.call('set(hotspot[myname].onvideoready, "")');krpano.call('set(hotspot[myname].onvideoplay, "")');


    I use this to check all the hotspots in my pano:

    Code
    for (var i = 0; i < krpano.get('hotspot.count'); i++) {	console.log(krpano.get('hotspot[ ' + i + ']'), krpano.get('hotspot[ ' + i + ']'));}


    The "myname"-hotspot appears in the resulting log but is not visible in my pano. Same data added via xml and everything is working fine.

    Any ideas how to fix this? I need to add Video-Hotspots dynamically.

  • Hi,

    that's because you're setting invalid settings - 'loadedurl', 'loadingurl' and 'url.html5' - none of the these three settings is correct!

    Just set the only 'url' setting!

    Xml attribute filters like '.html5' are static xml filters and can't be used in dynamic code.

    Best regards,
    Klaus

  • Thank you Klaus. Everything is working now. I don't now where I found 'loadurl' and 'loadingurl' *wink*
    What I do now is:

    Code
    ...krpano.call('set(hotspot[' + id + '].url, krpano/plugins/videoplayer.js)'); krpano.call('set(hotspot[' + id + '].videourl, content/video.mp4)');...

    And I found this in the documentation:
    "

    • Once the video is loaded, the value of the videourl attribute will be replaced by the url of the video file that was loaded.


    "

    Now things are a bit clearer for me.

Participate now!

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