Skip to content

Commit 8e247a5

Browse files
committed
Revert "Remove "cordova-plugin-media" example page"
This reverts commit 911df58.
1 parent 911df58 commit 8e247a5

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

examples/cordova/app.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"./modules/DialogPage",
55
"./modules/NetworkPage",
66
"./modules/CameraPage",
7-
"./modules/BarcodeScannerPage"
7+
"./modules/BarcodeScannerPage",
8+
"./modules/MediaPage"
89
].forEach(function(page) {
910
require(page).create();
1011
});

examples/cordova/audio/media.wav

180 KB
Binary file not shown.

examples/cordova/modules/MediaPage.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var PluginPage = require("./PluginPage");
2+
3+
var page = new PluginPage("Media", "cordova-media", function(parent) {
4+
5+
var path = tabris.app.getResourceLocation("audio/media.wav");
6+
// According to Media plugin documentation the media path must be
7+
// relative to the "www" folder under iOS
8+
if (tabris.device.get("platform") === "iOS") {
9+
path = path.substr(path.indexOf("/www/") + 5);
10+
}
11+
12+
var media = new Media(path, function() {
13+
console.log("Audio file loaded successfully");
14+
}, function(err) {
15+
console.log("Unable to play audio file: " + err.code + " - " + err.message);
16+
});
17+
18+
tabris.create("Button", {
19+
layoutData: {left: 10, top: 10, right: 10},
20+
text: "Play"
21+
}).appendTo(parent).on("select", function() {
22+
media.play();
23+
});
24+
25+
parent.on("dispose", function() {
26+
media.stop();
27+
media.release();
28+
});
29+
30+
});
31+
32+
module.exports = page;

0 commit comments

Comments
 (0)