¶ How To Use kiwappVideo.jskiwappVideo.js is a kiwapp.js based labrary which provides you simple methods to play video using native on Android and iOS. It can not work without Kiwapp.js loaded in your application. You have to initialize kiwapp before using the kiwappVideo methods. ¶ Initialize PlayerOnce Kiwapp is initialized, you can create a Player bridge.
The player needs a configuration to work. |
|
|
Creating the configuration. Here the player will mask all the webview surface. |
var config = {
origin_x : 0,
origin_y : 0,
width : window.innerWidth,
height : window.innerHeight
};
var player = new KWPlayer(config);
|
¶ Player MethodsAll the player methods are bridges calling native. |
|
¶ Play a videoOnce your player is ready, you can play videos. |
|
|
The method "play" of your player takes three arguments. |
|
|
The relative path to the video : |
var path = 'assets/myVideo.mp4';
|
|
[Optionnal - Default : 0] The start time of the video : |
var startTime = 10;
|
|
[Optionnal - Default : 1] The times the video will play again : |
var nbOfPlay = 2;
|
|
Listening the play action : |
player.on('KWPlayer:play', function(){
console.log("The video is playing.");
});
|
|
Playing the video : |
player.play(path, startTime, nbOfPlay);
|
¶ Pause a videoIf a video is playing, you can pause it. |
|
|
Listening the pause action : |
player.on('KWPlayer:pause', function(){
console.log("The video is pausing.");
});
|
|
Pausing the current video : |
player.pause();
|
¶ Resume a videoIf a video is in pause mode, you can resume it. |
|
|
Listening the resume action : |
player.on('KWPlayer:resume', function(){
console.log("The video is resuming.");
});
|
|
Resuming the current video |
player.resume();
|
¶ Stop a videoif a video is playing, you can stop it. |
|
|
Listening the stop action : |
player.on('KWPlayer:stop', function(){
console.log("The video is stopping.");
});
|
|
Stopping the current video |
player.stop();
|
¶ Change sound volumeYou can dynamically chnge the sound volume. |
|
|
The value has to be betwenn 0 and 100 : |
var soundVolume = 50;
|
|
Changing sound volume : |
player.sound(soundVolume);
|
¶ Know when a video is finishedYou can listen the video player to know when a video is finished and have a callback. |
|
|
Listening the end of the video : |
player.on('KWPlayer:finish', function(path){
console.log("The video "+path+" is finished.");
});
|