HTML Player MP3 Player

I want to insert a simple mp3 player into my website. MP3 player should have only 2 buttons (play and pause).

I found this: http://www.schillmania.com/projects/soundmanager2/ , and it seems nice, but I could not get it to have these two buttons. Can someone help me find a way to insert an mp3 player this way?

+4
source share
2 answers

A few years ago I was researching a topic for playing sound in a game, and SoundManager is an easier way to play audio using JavaScript.

First way:

If you go to the documentation, you will see that SoundManager intercepts clicks on MP3 links and plays them inline . The script assigns additional CSS classes to links to indicate their status (play / pause, etc.)

<a href="/mp3/foo.mp3" title="Play sound" class="sm2_button">Play Link</a> 

Check out the demo and more info.

Second way

If you want to use personalized buttons instead of links or images or any other html element, you can use the onClick event to play / pause the sound, for example:

Sound Download:

 <script> soundManager.onready(function() { soundManager.createSound({id:'mySound1',url:'/audio/foo.mp3'}); " }); </script> 

Buttons:

 <button id="play" onclick="soundManager.play('mySound1');return false">Play Button</button> <button id="pause" onclick="soundManager.pause('mySound1');return false">Pause Button</button> 

You can find more information about the API.

+5
source

In general, to play an audio file, there are two main ways to use a pre-created flash object (either to make it yourself if you have ActionScript skills) or use the HTML5 sound tag and javascript controls. If you are looking for a flash player, try activeden , which has 1000 small players to sell and hopefully something can satisfy your needs. Here's how you can insert a flash object into your page.

0
source

Source: https://habr.com/ru/post/1394244/


All Articles