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

Tuesday, April 25th 2017, 9:34am

Video end javascript event

Hi. Checked docs but havent found answer or just missed it - is there any js event fired when video playback is finished? Or any another way to handle that - timings etc ?
There is an "onready" callback - but it handles plugin initialization, while I need to watch content processing.

spacerywirtualne

Professional

Posts: 895

Location: Poland, Europe

Occupation: krpano developer : virtual tours

  • Send private message

2

Tuesday, April 25th 2017, 10:46am

Hello *smile*

If you have call JS action then try this.

plugin events

js bridge

example:

Source code

1
2
3
4
5
6
7
8
<layer name="video"       
...       
onvideoready="js(kr_onvideoready())"       
onvideoplay="js(kr_onvideoplay())"       
onvideopaused="js(kr_onvideopaused())"       
onvideocomplete="js(kr_onvideocomplete())       
onerror="js(kr_onerror())"       
/>



Source code

1
2
function kr_onvideoready() {        
...  }


Best regards
Piotr
Your own online, cloud tool for creating virtual tours - www.cms4vr.com

facebook page :: youtube

cms4vr team *thumbsup*

3

Tuesday, May 2nd 2017, 10:11am

Thanks for your answer, spacerywirtualne
But i'm still cannot fire a videoplayback-related events, so im likely need your help again.

Here is my xml config:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<krpano>
	<action name="startup" autorun="onstart">
 if(device.panovideosupport == false,
 error('Sorry, but panoramic videos are not supported by your current browser!');
 ,
 loadscene(videopano);
 );
	</action>
	<scene name="videopano" title="krpano Panoramic Video Example">
 <!-- include the videoplayer interface / skin (with VR support) -->
 <include url="skin/videointerface.xml" />
 <!-- include the videoplayer plugin -->
 <plugin name="video"
 url.html5="/static/krpano/viewer/plugins/videoplayer.js"
 pausedonstart="true"
 loop="false"
 volume="1.0"
 onloaded="add_video_sources();"
 onvideoready="jscall('alert(123);')"
 onvideoplay="jscall(alert(123);)"
 onvideopaused="js('alert(123);')"
 onvideocomplete="js(alert(123);)"
 onerror="jscall('alert(123);')"
 />
 <!-- use the videoplayer plugin as panoramic image source -->
 <image>
 <sphere url="plugin:video" />
 </image>
 <!-- set the default view -->
 <view hlookat="0" vlookat="0" fovtype="DFOV" fov="130" fovmin="75" fovmax="150" distortion="0.0" />
 <!-- add the video sources and play the video -->
 <action name="add_video_sources">
 videointerface_addsource('1024x512', '%CURRENTXML%/video-1024x512.mp4|%CURRENTXML%/video-1024x512.webm|%CURRENTXML%/iphone-audio.m4a', '%CURRENTXML%/video-1024x512-poster.jpg');
 videointerface_addsource('1920x960', '%CURRENTXML%/video-1920x960.mp4|%CURRENTXML%/video-1920x960.webm|%CURRENTXML%/iphone-audio.m4a', '%CURRENTXML%/video-1920x960-poster.jpg');
 if(device.ios,
 <!-- iOS Safari has a very slow 'video-to-webgl-texture' transfer, therefore use a low-res video by default -->
 videointerface_play('1024x512');
 ,
 videointerface_play('1920x960');
 );
 </action>
	</scene>
</krpano>


The other functionality - play and changing viewpoint - works fine. But js events are still not fired, regardless if i try to set them in a hardcode way like show above, or trying to call function available as window.kr_eventHandler()
Id just tried both js() and jscall, quoting argument and not - im just out of ideas what i miss.
Chrome debug console is clear at any cases.

Any suggestions what should I try to change?

This post has been edited 2 times, last edit by "eugene.k" (May 2nd 2017, 12:24pm)


4

Wednesday, May 3rd 2017, 9:46am

If i change config to
...

onloaded="test();"
onvideoready="test();"
onvideoplay="test();"
onvideopaused="test();"
...
<action name="test" type="Javascript">
alert(1234);
</action>

onload successfully alerts me, while other events do not

5

Thursday, May 4th 2017, 8:56am

Problem solved(thanks Klaus).
I used code from example "videopano". It includes videointerface.xml where Action "onvideocomplete" is overriden.

changing
set(plugin[video].onvideocomplete, skin_video_updatestate(); skin_show_playpause(); skin_show(); );
to
set(plugin[video].onvideocomplete, skin_video_updatestate(); skin_show_playpause(); skin_show(); %MY_OWN_ACTION_NAME%(); );

succesfully launched %MY_OWN_ACTION_NAME% on video playback end.