I started to use the krpano videoplayer from the krpano examples to show different videos tiggered by hotspots inside a single panorama.
The player works fast and fine and with the hotspots it's a great tool to enhance interactive storytelling with panoramas.
But to make it more convenient for users I need ot add at least a close button and later (sigh) video controls.
After some fail attempts I finally managed to get a close button on the screen that does what it should do, but I still fail to get it inside the videplayer_plugin which is needed for precise positioning.
I assume the closebutton_plugin should have the videoplayer_plugin as a parent, and if so, I must be doing something wrong with he syntax or whatever. I feel a bit uncomfortable with that layer stuff.
Can you please give me a hint or a similar example of how to correctly add it?
<action name="videoplayer_open">
if(layer[videoplayer_bg],
<!-- error -->
trace('videoplayer_open - there is already a videoplayer!'-);
,
<!-- step one - add a background layer and fade it in -->
addlayer(videoplayer_bg);
set(layer[videoplayer_bg].type, container);
set(layer[videoplayer_bg].zindex, 999999);
set(layer[videoplayer_bg].align, lefttop);
set(layer[videoplayer_bg].width, 100%);
set(layer[videoplayer_bg].height, 100%);
set(layer[videoplayer_bg].bgcolor, 0x000000);
set(layer[videoplayer_bg].bgalpha, 0.8);
set(layer[videoplayer_bg].bgcapture, true);
set(layer[videoplayer_bg].handcursor, false);
set(layer[videoplayer_bg].alpha, 0.0);
set(layer[videoplayer_bg].onclick, videoplayer_close() );
tween(layer[videoplayer_bg].alpha, 1.0, 0.5, default,
<!-- step two - after the fade-in add the videoplayer plugin -->
addlayer(videoplayer_plugin);
set(layer[videoplayer_plugin].parent, layer[videoplayer_bg]);
set(layer[videoplayer_plugin].align, center);
set(layer[videoplayer_plugin].loop, false);
set(layer[videoplayer_plugin].onclick, togglepause() );
set(layer[videoplayer_plugin].alpha, 0.0);
set(layer[videoplayer_plugin].scale, 0.0);
set(layer[videoplayer_plugin].onloaded, videoplayer_plugin_ready(%1) );
if('%2' != null, set(layer[videoplayer_plugin].posterurl,'%2'); );
if(device.flash,
set(layer[videoplayer_plugin].url,'%SWFPATH%/plugins/videoplayer.swf');
,
set(layer[videoplayer_plugin].url,'%SWFPATH%/plugins/videoplayer.js');
);
);
);
</action>
<action name="videoplayer_plugin_ready">
if(layer[videoplayer_plugin],
set(events[videoplayer_events].onresize, videoplayer_plugin_resize() );
set(layer[videoplayer_plugin].pausedonstart, true);
set(layer[videoplayer_plugin].onvideocomplete,
videoplayer_close());
set(layer[videoplayer_plugin].onvideoready,
videoplayer_plugin_resize();
tween(scale,1,0.5,linear);
tween(alpha,1,0.5,default, ifnot(device.ios, play() ) );
);
layer[videoplayer_plugin].playvideo(%1);
);
</action>
<action name="videoplayer_plugin_resize">
<!-- use 90% width or height of available screen size -->
div(aspect, layer[videoplayer_plugin].imagewidth, layer[videoplayer_plugin].imageheight);
mul(new_videowidth, stagewidth, 0.90);
div(new_videoheight, new_videowidth, aspect);
mul(max_videoheight, stageheight, 0.90);
if(new_videoheight GT max_videoheight,
copy(new_videoheight, max_videoheight);
mul(new_videowidth, new_videoheight, aspect);
);
roundval(new_videowidth);
roundval(new_videoheight);
copy(layer[videoplayer_plugin].width, new_videowidth);
copy(layer[videoplayer_plugin].height, new_videoheight);
</action>
<action name="videoplayer_close">
hideclosevideo();
set(events.[videoplayer_events].name, null);
if(layer[videoplayer_plugin], layer[videoplayer_plugin].pause() );
set(layer[videoplayer_bg].onclick, null);
tween(layer[videoplayer_plugin].scale, 0.0, 0.5, linear);
tween(layer[videoplayer_bg].alpha, 0.0, 0.5, default,
removelayer(videoplayer_plugin);
removelayer(videoplayer_bg);
);
</action>
Display More
Thanks a lot
Jürgen