update doc

This commit is contained in:
Gaven Henry 2016-06-10 12:00:06 +08:00
parent 6e42607423
commit 75dfdd236c

View File

@ -9,13 +9,14 @@ declare var Media: any;
* import {MediaPlugin} from 'ionic-native'; * import {MediaPlugin} from 'ionic-native';
* *
* *
* ...
* *
* * // Create a MediaPlugin instance. Expects path to file or url as argument
* // Playing a file
* var file = new MediaPlugin("path/to/file.mp3"); * var file = new MediaPlugin("path/to/file.mp3");
* *
* // Catch the Success & Error Output * // Catch the Success & Error Output
* // Platform Quirks
* // iOS calls success on completion of playback only
* // Android calls success on completion of playback AND on release()
* file.init.then(() => { * file.init.then(() => {
* console.log("Playback Finished"); * console.log("Playback Finished");
* }, (err) => { * }, (err) => {
@ -25,14 +26,30 @@ declare var Media: any;
* // play the file * // play the file
* file.play(); * file.play();
* *
* // skip to 10 seconds * // pause the file
* file.pause();
*
* // get current playback position
* file.getCurrentPosition().then((position) => {
* console.log(position);
* });
*
* // get file duration
* file.getDuration().then((duration) => {
* console.log(position);
* });
*
* // skip to 10 seconds (expects int value in ms)
* file.seekTo(10000); * file.seekTo(10000);
* *
* // stop plying the file * // stop playing the file
* file.stop(); * file.stop();
* *
* * // release the native audio resource
* ... * // Platform Quirks:
* // iOS simply create a new instance and the old one will be overwritten
* // Android you must call release() to destroy instances of media when you are done
* file.release();
* *
* // Recording to a file * // Recording to a file
* var newFile = new MediaPlugin("path/to/file.mp3"); * var newFile = new MediaPlugin("path/to/file.mp3");