Commit bae9b8cf authored by sgrebnov's avatar sgrebnov
Browse files

CB-8426 Add Windows platform section to Media plugin

parent 52bccd04
Loading
Loading
Loading
Loading
+4 −4
Changes for doc/index.md: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@ Although in the global scope, it is not available until after the `deviceready`
- iOS
- Windows Phone 7 and 8
- Tizen
- Windows 8
- Windows

## Windows Phone Quirks

@@ -361,7 +361,7 @@ Starts recording an audio file.
- Android
- iOS
- Windows Phone 7 and 8
- Windows 8
- Windows

### Quick Example

@@ -400,7 +400,7 @@ Starts recording an audio file.

        var myMedia = new Media("documents://beer.mp3")

### Windows 8 Quirks
### Windows Quirks

- If a full path is not provided, the recording is placed in the AppData/temp directory. This can be accessed via the `File` API using `LocalFileSystem.TEMPORARY` or 'ms-appdata:///temp/<filename>' URI.

@@ -454,7 +454,7 @@ Stops recording an audio file.
- Android
- iOS
- Windows Phone 7 and 8
- Windows 8
- Windows

### Quick Example

+13 −1
Changes for plugin.xml: 13 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -149,7 +149,19 @@ id="org.apache.cordova.media"

    <!-- windows8 -->
    <platform name="windows8">
        <js-module src="src/windows8/MediaProxy.js" name="MediaProxy">
        <js-module src="src/windows/MediaProxy.js" name="MediaProxy">
            <merges target="" />
        </js-module>

        <config-file target="package.appxmanifest" parent="/Package/Capabilities">
            <Capability Name="musicLibrary" />
            <DeviceCapability Name="microphone" />
        </config-file>
    </platform>

    <!-- windows -->
    <platform name="windows">
        <js-module src="src/windows/MediaProxy.js" name="MediaProxy">
            <merges target="" />
        </js-module>

+16 −3
Changes for src/windows/MediaProxy.js: 16 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -61,8 +61,11 @@ module.exports = {
            }
            else {
                lose && lose({ code: MediaError.MEDIA_ERR_ABORTED });
                return false; // unable to create
            }
        }

        return true; // successfully created
    },

    // Start playing the audio
@@ -74,12 +77,19 @@ module.exports = {
        var thisM = Media.get(id);
        // if Media was released, then node will be null and we need to create it again
        if (!thisM.node) {
            module.exports.create(win, lose, args);
            if (!module.exports.create(win, lose, args)) {
                // there is no reason to continue if we can't create media
                // corresponding callback has been invoked in create so we don't need to call it here
                return;
            }
        }

        Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_RUNNING);

        try {
            thisM.node.play();
            Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_RUNNING);
        } catch (err) {
            lose && lose({code:MediaError.MEDIA_ERR_ABORTED});
        }
    },

    // Stops the playing audio
@@ -201,7 +211,10 @@ module.exports = {
        var id = args[0];
        var thisM = Media.get(id);
        try {
            if (thisM.node) {
                thisM.node.onloadedmetadata = null;
                delete thisM.node;
            }
        } catch (err) {
            lose("Failed to release: "+err);
        }