Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-11941

Allow windows and windows phone apps to play audio located relative to the app root

    XMLWordPrintableJSON

Details

    Description

      I've had a look at the plugin code for windows and for the media source it looks like you can specify a url, a 'file://' or a 'cdvFile://'.

      The problem with the latter two is that they have to refer to either temp or persistent storage; it's not possible to specify that you want the audio file retrieving from a folder relative to the app root.

      I've manually copied over my audio files to:
      ...\AppData\Local\Packages\my_app_name\LocalState

      ...and confirmed that they do play if I specify a path of: ''cdvfile://localhost/persistent/my_audio.mp3''

      I've overriden the src/windows/MediaProxy.js code and hardcoded in various different paths for "thisM.node.src = srcUri.absoluteCanonicalUri;"

      I've tried:
      thisM.node.src = "ms-appx:///audio/my_audio_file.mp3"
      thisM.node.src = "ms-appx:///my_app_name/www/audio/my_audio_file.mp3"
      thisM.node.src = "audio/my_audio_file.mp3"

      The first two don't report any errors when trying to play but nothing is heard.
      The last one converts the source to:
      "ms-appx-web://my_app_name/www//audio/my_audio_file.mp3"
      ... and reports an invalid src error when attempting to play.

      So, it looks like something in the C# code also need changing.

      As a work around I'll have to (if possible) check if the media files exist in the persistent folder and if not copy them over from the app audio folder.

      Alternatively I could install the media files into the persistent folder when the app is installed but I haven't found a way to do this yet.

      Thanks

      Attachments

        Activity

          People

            Unassigned Unassigned
            JulesOnJira julian hill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: