286
Views
3
Comments
Play Audio in Mobile App using URL
Question

How to  Play audio from URL like "https://www.noiseaddicts.com/samples_1w72b820/2242.mp3"

There are many topics on playing audio but nothing seems working.
I want to play an audio on clicking play button.
Please Help!!!

2022-11-12 11-28-30
Gonçalo Martins
Staff

John Snow wrote:

How to  Play audio from URL like " https://www.noiseaddicts.com/samples_1w72b820/2242.mp3"

There are many topics on playing audio but nothing seems working.
I want to play an audio on clicking play button.
Please Help!!!

Hi there.

You can do something like I explained on a previous post.

So, you can do something like:

function playSound(url) {
    var a = new Audio(url);
    a.play();
}

or simply:

<a href="#" onclick="new Audio('https://www.noiseaddicts.com/samples_1w72b820/2242.mp3').play()">Click here to play the sound</a>

Cheers,

GM

2017-08-09 19-45-50
John Snow

Gonçalo Martins wrote:

John Snow wrote:

How to  Play audio from URL like " https://www.noiseaddicts.com/samples_1w72b820/2242.mp3"

There are many topics on playing audio but nothing seems working.
I want to play an audio on clicking play button.
Please Help!!!

Hi there.

You can do something like I explained on a previous post.

So, you can do something like:

function playSound(url) {
    var a = new Audio(url);
    a.play();
}

or simply:

<a href="#" onclick="new Audio('https://www.noiseaddicts.com/samples_1w72b820/2242.mp3').play()">Click here to play the sound</a>

Cheers,

GM


The above solution works only when I Open the App in Browser. It Does not work in mobile. Any reason Why?
Thanks

2018-05-30 15-57-24
Daniel Marcelino
Staff

Hi, you must use a URL with "https" (be aware that some online audio sounds don't provide an HTTPS version, only HTTP, this will not work in mobile), using this you will be able to play that within the mobile app in the device after generating the .apk. 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.