From 75dfdd236c2673afa48ad82345fd68fd9cf7b0bf Mon Sep 17 00:00:00 2001 From: Gaven Henry Date: Fri, 10 Jun 2016 12:00:06 +0800 Subject: [PATCH] update doc --- src/plugins/media.ts | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/plugins/media.ts b/src/plugins/media.ts index 5e664802..f7ab6a21 100644 --- a/src/plugins/media.ts +++ b/src/plugins/media.ts @@ -9,13 +9,14 @@ declare var Media: any; * import {MediaPlugin} from 'ionic-native'; * * - * ... * - * - * // Playing a file + * // Create a MediaPlugin instance. Expects path to file or url as argument * var file = new MediaPlugin("path/to/file.mp3"); * * // 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(() => { * console.log("Playback Finished"); * }, (err) => { @@ -25,14 +26,30 @@ declare var Media: any; * // play the file * 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); * - * // stop plying the file + * // stop playing the file * 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 * var newFile = new MediaPlugin("path/to/file.mp3");