Reputation: 1
I'm making it short: I have a audio player (audio.js) which plays a song. But I want to make the audio pause when I click on a button above. This is what it looks like: (oh sorry, I dont have the permission to upload images) :D
"Hier die Musik ausschalten" is german and means "Stop playing".
This is my code:
<body>
<h1>Mein Audio-Test</h1>
<button class="noMusic">Hier die Musik ausschalten!</button>
<!-----Der Audio-Player--->
<audio src="audio/Palace%20Cat%20-%20Crookshanks.mp3" preload="auto" />
<!--------- Scripts für Audio --------------->
<script src="audio/audiojs/audio.js"></script>
<script>
audiojs.events.ready(function() {
var as = audiojs.createAll();
});
</script>
<!----------- jquery ----------->
<script type="text/javascript" src="jquery/jquery-1.11.1.js"></script>
<!-------- ----------- ------>
<script>
$( ".noMusic" ).click(function( event ) {
var player = this.settings.createPlayer;
container[audiojs].helpers.removeClass(this.wrapper, player.playingClass);
});
</script>
</body>
I really dont know what I'm wrong. Does anyone have an idea? Thank you very much!
Upvotes: 0
Views: 296
Reputation: 23262
I'm not sure what audio.js
is for, but it's simple to hook into the browser audio API:
var $player = $('audio');
$('.noMusic').click(function (event) {
$player.get(0).pause();
});
Upvotes: 2