You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, August 22nd 2016, 5:31pm

Adding Video-Hotspots via js

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


Source code

1
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:

Source code

1
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.

2

Tuesday, August 23rd 2016, 10:50am

Perhaps this happens because videos are plugins not real hotspots?
But I want to create a 3d-distorted hotspot like discibed here: #[url]http://krpano.com/plugins/videoplayer/#[/url]

I tried using addplugin() instead of addhotspot() but then I don't now how to make it a hotspot-node.

3

Tuesday, August 23rd 2016, 7:43pm

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

4

Wednesday, August 24th 2016, 10:08am

Thank you Klaus. Everything is working now. I don't now where I found 'loadurl' and 'loadingurl' ;-)
What I do now is:

Source code

1
...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.