强制播放MP3而不是下载

强制播放MP3而不是下载

本文介绍了强制播放MP3而不是下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有链接(请注意:这是不是一个直接的MP3网址)



当我打这个URL时,它启动一个mp3文件的下载。



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

这是下载mp3文件而不是播放。



我的目标是通过点击图片而不是下载该文件,在新窗口中播放该mp3。



任何帮助将不胜感激

编辑:正如我上面提到的,我没有直接的mp3链接。我拥有的链接(比如说www.example.com/test)只是一个重定向到mp3链接的url(例如www.example.com/sounds/abc.mp3),然后我可以选择下载该mp3。 / p>

我得到的答案是播放mp3,如果我有mp3文件或我​​知道mp3文件的直接网址。



我正在寻找的解决方案就像。它首先将该mp3下载到临时文件夹中,然后播放它。一旦音乐播放器关闭,该文件将从临时文件夹中删除。

您可以使用HTML5:

 < audio src =/ test / audio.ogg> 
您的浏览器不支持HTML5音频播放器,请升级您的浏览器。
< / audio>

或者使用跨浏览器解决方案:


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.

解决方案

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/

这篇关于强制播放MP3而不是下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 04:52