1

I have a link say http://www.example.com/test (Please note: This is not a direct mp3 url)

When I hit this url, it initiates a download of mp3 file.

Right now I am using this

<a href="http://www.example.com/test"><img src="img/play22.png" width="20" height="20">

This is downloading the mp3 file instead of playing.

My aim is to play that mp3 in new window with a player on my site by clicking an image instead of downloading that file.

Any help would be appreciated

EDIT: Like I mentioned above I don't have direct mp3 link. The link I have (say www.example.com/test) is just a url which redirects to the exact mp3 link (say www.example.com/sounds/abc.mp3) and then I get option for download that mp3.

The answers I am getting is to play an mp3 if I have the mp3 file or I know the direct url of mp3 file.

The solution I am looking for will be like. It first downloads that mp3 in a temp folder and then plays it. The file will be deleted from temp folder once music player is closed.

CC BY-SA 3.0
3
  • If you link directly to the file, the user has the choice of downloading or playing it depending on their browser settings. If you want to only ever stream the MP3, you'd have to either build an mp3 player app from scratch, or use an existing one; but that's beyond the scope of a question like this. Commented Jan 30, 2014 at 8:15
  • Look into the audio tag which (in some browsers) can play the MP3 for you inline (others require for example ogg format instead). Commented Jan 30, 2014 at 8:16
  • Please read the comments I edited in my question Ken and BFDatabaseAdmin Commented Jan 30, 2014 at 9:24

2 Answers 2

2

You may use HTML5:

<audio src="/test/audio.ogg">
    Your browser does not support HTML5 audio player, please upgrade your browser.
</audio>

Or use a cross browser solution:
http://mediaelementjs.com/

CC BY-SA 3.0
Sign up to request clarification or add additional context in comments.

Comments

0

Maybe you are looking for this:

HTML

<embed src="http://www.example.com/test">

Check embed tag here.

CC BY-SA 3.0

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.