Giter VIP home page Giter VIP logo

Comments (5)

zeallin avatar zeallin commented on July 17, 2024 8

Here is what I try and it works in version 5.0.2:

var path = 'media/sounds/warning.mp3'

// Need to unescape if path have '%20' component
var filePath =
              decodeURI(cordova.file.applicationDirectory) + 'www/' + path;

// iOS need to remove file://
if (device.platform.toLowerCase() == 'ios') {
  filePath = filePath.replace('file://', '');
}

var audio = new Media(filePath, null,
            function(e) {
            console.log(JSON.stringify(e));
          }, function(status) {

          });

audio.setVolume('1.0');
audio.play()

from cordova-plugin-media.

nexorianus avatar nexorianus commented on July 17, 2024 3

removing file:// works like a charm.
Sadly this is not documented anywhere except in this report.

from cordova-plugin-media.

janpio avatar janpio commented on July 17, 2024

Can you open the URL you are trying to load with the plugin when just creating a simple link and clicking on it?

from cordova-plugin-media.

si-harps avatar si-harps commented on July 17, 2024

Thanks for the quick response. Yes i am able to open the file using a link in the application, also via the browser on my local machine (attached screenshots for clarity)

screen shot 2018-09-12 at 11 07 41

screen shot 2018-09-12 at 11 07 54

screen-shot-2018-09-12-at-10 59 42

from cordova-plugin-media.

sefrem avatar sefrem commented on July 17, 2024

@zeal-hexsave Duude, you saved my life with this comment 'Need to unescape if path have '%20' component'. I've been beating my head on the problem of sounds not playing at least for a couple of days. Thank you so much.

from cordova-plugin-media.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.