Sie sind nicht angemeldet.

1

Dienstag, 25. April 2017, 09:34

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.

Beiträge: 1 117

Wohnort: Poland, Europe

Beruf: krpano developer : virtual tours : the cms4vr owner

  • Nachricht senden

2

Dienstag, 25. April 2017, 10:46

Hello *smile*

If you have call JS action then try this.

plugin events

js bridge

example:

Quellcode

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())"       
/>



Quellcode

1
2
function kr_onvideoready() {        
...  }


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

facebook page :: youtube :: wiki.cms4vr.com

cms4vr team *thumbsup*

3

Dienstag, 2. Mai 2017, 10:11

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:

Quellcode

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?

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »eugene.k« (2. Mai 2017, 12:24)


4

Mittwoch, 3. Mai 2017, 09:46

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

Donnerstag, 4. Mai 2017, 08:56

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.