cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nikhi...@apache.org
Subject cordova-plugin-media git commit: Readme: Add fenced code blocks with langauage hints
Date Wed, 18 May 2016 19:08:17 GMT
Repository: cordova-plugin-media
Updated Branches:
  refs/heads/master 1cbc49604 -> c8505a6a5


Readme: Add fenced code blocks with langauage hints


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/commit/c8505a6a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/tree/c8505a6a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/diff/c8505a6a

Branch: refs/heads/master
Commit: c8505a6a5139fd60ffc2a7a77c7c5557826fa5c7
Parents: 1cbc496
Author: Nikhil Khandelwal <nikhilkh@microsoft.com>
Authored: Wed May 18 12:08:06 2016 -0700
Committer: Nikhil Khandelwal <nikhilkh@microsoft.com>
Committed: Wed May 18 12:08:06 2016 -0700

----------------------------------------------------------------------
 README.md | 531 ++++++++++++++++++++++++++++++---------------------------
 1 file changed, 276 insertions(+), 255 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-media/blob/c8505a6a/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 7912e21..3d2278b 100644
--- a/README.md
+++ b/README.md
@@ -37,17 +37,21 @@ This plugin defines a global `Media` Constructor.
 
 Although in the global scope, it is not available until after the `deviceready` event.
 
-    document.addEventListener("deviceready", onDeviceReady, false);
-    function onDeviceReady() {
-        console.log(Media);
-    }
+```js
+document.addEventListener("deviceready", onDeviceReady, false);
+function onDeviceReady() {
+    console.log(Media);
+}
+```
 
 Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20Media%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC)
 
 
 ## Installation
 
-    cordova plugin add cordova-plugin-media
+```bash
+cordova plugin add cordova-plugin-media
+```
 
 ## Supported Platforms
 
@@ -66,7 +70,9 @@ Report issues with this plugin on the [Apache Cordova issue tracker](https://iss
 
 ## Media
 
-    var media = new Media(src, mediaSuccess, [mediaError], [mediaStatus]);
+```js
+var media = new Media(src, mediaSuccess, [mediaError], [mediaStatus]);
+```
 
 ### Parameters
 
@@ -149,27 +155,28 @@ Returns the current amplitude of the current recording.
 
 ### Quick Example
 
-    // Audio player
-    //
-    var my_media = new Media(src, onSuccess, onError);
-
-    // Record audio
-    my_media.startRecord();
-
-    mediaTimer = setInterval(function () {
-        // get media amplitude
-        my_media.getCurrentAmplitude(
-            // success callback
-            function (amp) {
-                console.log(amp + "%");
-            },
-            // error callback
-            function (e) {
-                console.log("Error getting amp=" + e);
-            }
-        );
-    }, 1000);
-
+```js
+// Audio player
+//
+var my_media = new Media(src, onSuccess, onError);
+
+// Record audio
+my_media.startRecord();
+
+mediaTimer = setInterval(function () {
+    // get media amplitude
+    my_media.getCurrentAmplitude(
+        // success callback
+        function (amp) {
+            console.log(amp + "%");
+        },
+        // error callback
+        function (e) {
+            console.log("Error getting amp=" + e);
+        }
+    );
+}, 1000);
+```
 
 ## media.getCurrentPosition
 
@@ -185,27 +192,28 @@ Returns the current position within an audio file.  Also updates the
`Media` obj
 
 ### Quick Example
 
-    // Audio player
-    //
-    var my_media = new Media(src, onSuccess, onError);
-
-    // Update media position every second
-    var mediaTimer = setInterval(function () {
-        // get media position
-        my_media.getCurrentPosition(
-            // success callback
-            function (position) {
-                if (position > -1) {
-                    console.log((position) + " sec");
-                }
-            },
-            // error callback
-            function (e) {
-                console.log("Error getting pos=" + e);
+```js
+// Audio player
+//
+var my_media = new Media(src, onSuccess, onError);
+
+// Update media position every second
+var mediaTimer = setInterval(function () {
+    // get media position
+    my_media.getCurrentPosition(
+        // success callback
+        function (position) {
+            if (position > -1) {
+                console.log((position) + " sec");
             }
-        );
-    }, 1000);
-
+        },
+        // error callback
+        function (e) {
+            console.log("Error getting pos=" + e);
+        }
+    );
+}, 1000);
+```
 
 ## media.getDuration
 
@@ -216,24 +224,25 @@ Returns the duration of an audio file in seconds. If the duration is
unknown, it
 
 ### Quick Example
 
-    // Audio player
-    //
-    var my_media = new Media(src, onSuccess, onError);
-
-    // Get duration
-    var counter = 0;
-    var timerDur = setInterval(function() {
-        counter = counter + 100;
-        if (counter > 2000) {
-            clearInterval(timerDur);
-        }
-        var dur = my_media.getDuration();
-        if (dur > 0) {
-            clearInterval(timerDur);
-            document.getElementById('audio_duration').innerHTML = (dur) + " sec";
-        }
-    }, 100);
-
+```js
+// Audio player
+//
+var my_media = new Media(src, onSuccess, onError);
+
+// Get duration
+var counter = 0;
+var timerDur = setInterval(function() {
+    counter = counter + 100;
+    if (counter > 2000) {
+        clearInterval(timerDur);
+    }
+    var dur = my_media.getDuration();
+    if (dur > 0) {
+        clearInterval(timerDur);
+        document.getElementById('audio_duration').innerHTML = (dur) + " sec";
+    }
+}, 100);
+```
 
 ## media.pause
 
@@ -244,26 +253,27 @@ Pauses playing an audio file.
 
 ### Quick Example
 
+```js
+// Play audio
+//
+function playAudio(url) {
+    // Play the audio file at url
+    var my_media = new Media(url,
+        // success callback
+        function () { console.log("playAudio():Audio Success"); },
+        // error callback
+        function (err) { console.log("playAudio():Audio Error: " + err); }
+    );
+
     // Play audio
-    //
-    function playAudio(url) {
-        // Play the audio file at url
-        var my_media = new Media(url,
-            // success callback
-            function () { console.log("playAudio():Audio Success"); },
-            // error callback
-            function (err) { console.log("playAudio():Audio Error: " + err); }
-        );
-
-        // Play audio
-        my_media.play();
-
-        // Pause after 10 seconds
-        setTimeout(function () {
-            my_media.pause();
-        }, 10000);
-    }
+    my_media.play();
 
+    // Pause after 10 seconds
+    setTimeout(function () {
+        my_media.pause();
+    }, 10000);
+}
+```
 
 ## media.pauseRecord
 
@@ -279,57 +289,61 @@ Pauses recording an audio file.
 
 ### Quick Example
 
+```js
+// Record audio
+//
+function recordAudio() {
+    var src = "myrecording.mp3";
+    var mediaRec = new Media(src,
+        // success callback
+        function() {
+            console.log("recordAudio():Audio Success");
+        },
+
+        // error callback
+        function(err) {
+            console.log("recordAudio():Audio Error: "+ err.code);
+        });
+
     // Record audio
-    //
-    function recordAudio() {
-        var src = "myrecording.mp3";
-        var mediaRec = new Media(src,
-            // success callback
-            function() {
-                console.log("recordAudio():Audio Success");
-            },
-
-            // error callback
-            function(err) {
-                console.log("recordAudio():Audio Error: "+ err.code);
-            });
-
-        // Record audio
-        mediaRec.startRecord();
-
-        // Pause Recording after 5 seconds
-        setTimeout(function() {
-            my_media.pauseRecord();
-        }, 5000);
-    }
+    mediaRec.startRecord();
+
+    // Pause Recording after 5 seconds
+    setTimeout(function() {
+        my_media.pauseRecord();
+    }, 5000);
+}
+```
 
 ## media.play
 
 Starts or resumes playing an audio file.
 
-    media.play();
-
+```js
+media.play();
+```
 
 ### Quick Example
 
+```js
+// Play audio
+//
+function playAudio(url) {
+    // Play the audio file at url
+    var my_media = new Media(url,
+        // success callback
+        function () {
+            console.log("playAudio():Audio Success");
+        },
+        // error callback
+        function (err) {
+            console.log("playAudio():Audio Error: " + err);
+        }
+    );
     // Play audio
-    //
-    function playAudio(url) {
-        // Play the audio file at url
-        var my_media = new Media(url,
-            // success callback
-            function () {
-                console.log("playAudio():Audio Success");
-            },
-            // error callback
-            function (err) {
-                console.log("playAudio():Audio Error: " + err);
-            }
-        );
-        // Play audio
-        my_media.play();
-    }
-
+    my_media.play();
+}
+```
 
 ### iOS Quirks
 
@@ -366,14 +380,15 @@ function for any `Media` resource that is no longer needed.
 
 ### Quick Example
 
-    // Audio player
-    //
-    var my_media = new Media(src, onSuccess, onError);
-
-    my_media.play();
-    my_media.stop();
-    my_media.release();
+```js
+// Audio player
+//
+var my_media = new Media(src, onSuccess, onError);
 
+my_media.play();
+my_media.stop();
+my_media.release();
+```
 
 ## media.resumeRecord
 
@@ -389,35 +404,36 @@ Resume recording an audio file.
 
 ### Quick Example
 
+```js
+// Record audio
+//
+function recordAudio() {
+    var src = "myrecording.mp3";
+    var mediaRec = new Media(src,
+        // success callback
+        function() {
+            console.log("recordAudio():Audio Success");
+        },
+
+        // error callback
+        function(err) {
+            console.log("recordAudio():Audio Error: "+ err.code);
+        });
+
     // Record audio
-    //
-    function recordAudio() {
-        var src = "myrecording.mp3";
-        var mediaRec = new Media(src,
-            // success callback
-            function() {
-                console.log("recordAudio():Audio Success");
-            },
-
-            // error callback
-            function(err) {
-                console.log("recordAudio():Audio Error: "+ err.code);
-            });
-
-        // Record audio
-        mediaRec.startRecord();
-
-        // Pause Recording after 5 seconds
-        setTimeout(function() {
-            my_media.pauseRecord();
-        }, 5000);
-
-        // Resume Recording after 10 seconds
-        setTimeout(function() {
-            my_media.resumeRecord();
-        }, 10000);
-    }
+    mediaRec.startRecord();
+
+    // Pause Recording after 5 seconds
+    setTimeout(function() {
+        my_media.pauseRecord();
+    }, 5000);
 
+    // Resume Recording after 10 seconds
+    setTimeout(function() {
+        my_media.resumeRecord();
+    }, 10000);
+}
+```
 
 ## media.seekTo
 
@@ -432,15 +448,16 @@ Sets the current position within an audio file.
 
 ### Quick Example
 
-    // Audio player
-    //
-    var my_media = new Media(src, onSuccess, onError);
-        my_media.play();
-    // SeekTo to 10 seconds after 5 seconds
-    setTimeout(function() {
-        my_media.seekTo(10000);
-    }, 5000);
-
+```js
+// Audio player
+//
+var my_media = new Media(src, onSuccess, onError);
+    my_media.play();
+// SeekTo to 10 seconds after 5 seconds
+setTimeout(function() {
+    my_media.seekTo(10000);
+}, 5000);
+```
 
 ### BlackBerry 10 Quirks
 
@@ -463,34 +480,35 @@ Set the volume for an audio file.
 
 ### Quick Example
 
-    // Play audio
-    //
-    function playAudio(url) {
-        // Play the audio file at url
-        var my_media = new Media(url,
-            // success callback
-            function() {
-                console.log("playAudio():Audio Success");
-            },
-            // error callback
-            function(err) {
-                console.log("playAudio():Audio Error: "+err);
-        });
-
-        // Play audio
-        my_media.play();
+```js
+// Play audio
+//
+function playAudio(url) {
+    // Play the audio file at url
+    var my_media = new Media(url,
+        // success callback
+        function() {
+            console.log("playAudio():Audio Success");
+        },
+        // error callback
+        function(err) {
+            console.log("playAudio():Audio Error: "+err);
+    });
 
-        // Mute volume after 2 seconds
-        setTimeout(function() {
-            my_media.setVolume('0.0');
-        }, 2000);
+    // Play audio
+    my_media.play();
 
-        // Set volume to 1.0 after 5 seconds
-        setTimeout(function() {
-            my_media.setVolume('1.0');
-        }, 5000);
-    }
+    // Mute volume after 2 seconds
+    setTimeout(function() {
+        my_media.setVolume('0.0');
+    }, 2000);
 
+    // Set volume to 1.0 after 5 seconds
+    setTimeout(function() {
+        my_media.setVolume('1.0');
+    }, 5000);
+}
+```
 
 ## media.startRecord
 
@@ -507,25 +525,26 @@ Starts recording an audio file.
 
 ### Quick Example
 
-    // Record audio
-    //
-    function recordAudio() {
-        var src = "myrecording.mp3";
-        var mediaRec = new Media(src,
-            // success callback
-            function() {
-                console.log("recordAudio():Audio Success");
-            },
-
-            // error callback
-            function(err) {
-                console.log("recordAudio():Audio Error: "+ err.code);
-            });
-
-        // Record audio
-        mediaRec.startRecord();
-    }
+```js
+// Record audio
+//
+function recordAudio() {
+    var src = "myrecording.mp3";
+    var mediaRec = new Media(src,
+        // success callback
+        function() {
+            console.log("recordAudio():Audio Success");
+        },
+
+        // error callback
+        function(err) {
+            console.log("recordAudio():Audio Error: "+ err.code);
+        });
 
+    // Record audio
+    mediaRec.startRecord();
+}
+```
 
 ### Android Quirks
 
@@ -562,30 +581,31 @@ Stops playing an audio file.
 
 ### Quick Example
 
-    // Play audio
-    //
-    function playAudio(url) {
-        // Play the audio file at url
-        var my_media = new Media(url,
-            // success callback
-            function() {
-                console.log("playAudio():Audio Success");
-            },
-            // error callback
-            function(err) {
-                console.log("playAudio():Audio Error: "+err);
-            }
-        );
-
-        // Play audio
-        my_media.play();
+```js
+// Play audio
+//
+function playAudio(url) {
+    // Play the audio file at url
+    var my_media = new Media(url,
+        // success callback
+        function() {
+            console.log("playAudio():Audio Success");
+        },
+        // error callback
+        function(err) {
+            console.log("playAudio():Audio Error: "+err);
+        }
+    );
 
-        // Pause after 10 seconds
-        setTimeout(function() {
-            my_media.stop();
-        }, 10000);
-    }
+    // Play audio
+    my_media.play();
 
+    // Pause after 10 seconds
+    setTimeout(function() {
+        my_media.stop();
+    }, 10000);
+}
+```
 
 ## media.stopRecord
 
@@ -602,31 +622,32 @@ Stops recording an audio file.
 
 ### Quick Example
 
-    // Record audio
-    //
-    function recordAudio() {
-        var src = "myrecording.mp3";
-        var mediaRec = new Media(src,
-            // success callback
-            function() {
-                console.log("recordAudio():Audio Success");
-            },
-
-            // error callback
-            function(err) {
-                console.log("recordAudio():Audio Error: "+ err.code);
-            }
-        );
-
-        // Record audio
-        mediaRec.startRecord();
+```js
+// Record audio
+//
+function recordAudio() {
+    var src = "myrecording.mp3";
+    var mediaRec = new Media(src,
+        // success callback
+        function() {
+            console.log("recordAudio():Audio Success");
+        },
+
+        // error callback
+        function(err) {
+            console.log("recordAudio():Audio Error: "+ err.code);
+        }
+    );
 
-        // Stop recording after 10 seconds
-        setTimeout(function() {
-            mediaRec.stopRecord();
-        }, 10000);
-    }
+    // Record audio
+    mediaRec.startRecord();
 
+    // Stop recording after 10 seconds
+    setTimeout(function() {
+        mediaRec.stopRecord();
+    }, 10000);
+}
+```
 
 ### Tizen Quirks
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message