Protect audio files in HTML5 audio tags

只愿长相守 提交于 2019-12-06 11:06:05

问题


I am making a site which will have music playing on the site using HTML5 tags and was wondering if there was any way to protect the files from being downloaded?

I am calling the music file through PHP and if needed it selects an OGG file for browsers that don't support MP3.

The actual files are inaccessible to the public but the PHP file can be downloaded and played.

I was wondering if there was anything I could do which would stop people downloading the file but allow it to be played through the tags?

EDIT:

I know that the user must be able to access the URL for the file to play.

I am wondering how to prevent download when the user accesses the file without the tag.

I believe YouTube do a similar thing with the HTML5 video tag (either that or all YouTube videos are now free to download)

EDIT 2:

I have noticed that when a file is downloaded by the user, it does not get passed a HTTP_CACHE_CONTROL variable in the $_SERVER array.

Would this be able to prevent people downloading the file by returning a blank file if they directly download it?


回答1:


and was wondering if there was any way to protect the files from being downloaded?

Nope. The browser has to download the file, hence there is nothing you can do to protect it. You could start using a streaming solution that would make downloading the file at least more difficult, but then you'd have to use proprietary technology like Flash.



来源:https://stackoverflow.com/questions/8634955/protect-audio-files-in-html5-audio-tags

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!