goldfire / howler.js

Javascript audio library for the modern web.
https://howlerjs.com
MIT License
24.02k stars 2.24k forks source link

sound.state() = loading, but the sound never plays #1346

Open duvanme1 opened 4 years ago

duvanme1 commented 4 years ago

Hi, Guys. I hope you can help me. I'm new to this, and I'm building a very simple radio station from scratch, but the audio is never played in my website. When I check the state it's always loading, and I haven't been able to spot what the issue is. This my my html:

<!DOCTYPE html>
<html>
<head>
    <title>Radio station</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <ul>
        <li id="first">The garden</li>
    </ul>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/howler/2.2.0/howler.js"></script>    
<script type="text/javascript" src="script.js"></script>
</body>
</html>
var sound = new Howl({
    src: 'http://prclive1.listenon.in:9960/?fbclid=IwAR1bAO9Hf-yvOGrjKVVdYt0XXnqo85o1G2IXWrzVtjIujOit5JqW7oQUtfI',
    format: ['mp3', 'aac'] 
});

var li = document.querySelector("#first");
li.addEventListener("click", function(){
     sound.play();  
})

I thought that maybe it was my code but I've tried alerts and sounds stored in my pc, and it works fine. Maybe it's the link which would be weird since I took it from one of the working links in the radio demo. Thanks in advance!

gz1992 commented 4 years ago

I had the same problem on WebView. For users that access our website via instagram, on Android, sound.state() keeps on loading. if it goes to loaded, there is a playerror:

playback was unable to start . this is most commonly an issue on mobile devices and chrome where playback was not within a user interaction