Javascript html5 mp3player的动态地址和未知文件名,如下面的代码所示
正如你可以看到下面的代码,我已经是完全功能读取上传的mp3文件从用户,然后通过它的flash播放器播放Javascript html5 mp3player的动态地址和未知文件名,如下面的代码所示,javascript,php,html,media-player,flash,Javascript,Php,Html,Media Player,Flash,正如你可以看到下面的代码,我已经是完全功能读取上传的mp3文件从用户,然后通过它的flash播放器播放 if($uplfile !="") $url = $my_base_url.$my_website_base."/modules/upload/attachments/".$uplfile; else $url = $this->get_template_vars('enc_url'); $info = pathinfo($url); if ($info["e
if($uplfile !="")
$url = $my_base_url.$my_website_base."/modules/upload/attachments/".$uplfile;
else
$url = $this->get_template_vars('enc_url');
$info = pathinfo($url);
if ($info["extension"] == "mp3")
{
{/php}
<center>
<object type="application/x-shockwave-flash" data="{$my_base_url}{$my_website_base}/templates/{$the_template}/img/player_mp3_maxi.swf" width="200" height="20">
<param name="movie" value="{$my_base_url}{$my_website_base}/templates/{$the_template}/img/player_mp3_maxi.swf" />
<param name="bgcolor" value="#ffffff" />
{php}
echo ' <param name="FlashVars" value="'.urldecode($url).'" />
<param name="FlashVars" value="mp3='.$url.'&showstop=1&showinfo=1&showvolume=1" />
</object>
</center>';
但是我想用html5播放器来代替。我会这样说
<audio controls>
<source src=" **? Don't Know What to put ?** " type="audio/ogg">
<source src=" **? Don't Know What to put ?** " type="audio/mpeg">
</audio>
为了读取文件,我尝试了所有可能用于源代码的东西,但仍然无法做到这一点。请被告知,我不知道文件名,是未知的,将由用户上传。
提前谢谢。这是我第一次使用这个网站,所以如果我没有严格遵守提问规则,请忽略
编辑
我使用了以下代码
我保留了HTML5和javascript,看看哪一个可以工作。我想摆脱swf闪存,因为它与移动设备兼容,所以可以正常工作
{php}
global $db,$my_base_url,$my_pligg_base;
$lid = $this->get_template_vars('link_id');
$uplfile = $db->get_var("select file_name from ".table_prefix."files where file_link_id='".$lid."' and file_size='orig'");
if($uplfile !="")
$url = $my_base_url.$my_pligg_base."/modules/upload/attachments/".$uplfile;
else
$url = $this->get_template_vars('enc_url');
$info = pathinfo($url);
if ($info["extension"] == "mp3")
{
{/php}
<audio controls>
<source src=" $url " type="audio/ogg">
<source src=" $url" type="audio/mpeg">
</audio>
<script type="text/javascript">
function music(track){
$('#audioPlayer').attr('src', track);
$('#audioPlayer').attr('autoplay', 'autoplay');
$.get();
}
function pauseAudio(){
$('#audioPlayer').get(0).pause();
}
</script>
<img alt="" onclick="music('http://www.raphmond.com/modules/upload/attachments/'); return false;" src="http://www.raphmond.com/templates/coolstrap/img/play.png">
<img alt="" onclick="pauseAudio(); return false;" src="http://www.raphmond.com/templates/coolstrap/img/pause.png">
<audio id="audioPlayer" src=""></audio>
<center>
<object type="application/x-shockwave-flash" data="{$my_base_url}{$my_pligg_base}/templates/{$the_template}/img/player_mp3_maxi.swf" width="200" height="20">
<param name="movie" value="{$my_base_url}{$my_pligg_base}/templates/{$the_template}/img/player_mp3_maxi.swf" />
<param name="bgcolor" value="#ffffff" />
{php}
echo ' <param name="FlashVars" value="'.urldecode($url).'" />
<param name="FlashVars" value="mp3='.$url.'&showstop=1&showinfo=1&showvolume=1" />
</object>
</center>';
这应该行得通
假设您的路径实际有效,应该没有问题。您好,问题是所有提交的文件都将进入文件夹,然后它们将被发布。该文件的名称是由用户和网站应该只是简单地播放后上传。动态地址$my_base\u url.$my_website\u base./modules/upload/attachments/用于区分每个用户提交的内容。对不起,你的回答没有帮助。事实上,就是这么简单。您在$url变量中已经有上载的文件url。您的src属性的值应为$url。@Bob Far,ssnobody没有意义。如果文件已上载且路径未断开,这应该对您有效。@BobFar,请不要编辑我的文章试图解决您的问题-编辑您自己的:为了记录,请使用完整路径进行尝试。您在编辑中使用的是相对的。请使用您的尝试更新您的帖子,将原始帖子与“编辑”和“新尝试”分开,我会查看。您没有在onclick事件的音乐函数调用中指定路径中的文件。你有http://www.raphmond.com/modules/upload/attachments/,应该是http://www.raphmond.com/modules/upload/attachments/myfile.mp3The 文件未知。每次用户放下mp3时,它都会被放在该文件夹中。正如您在swf版本中所看到的,没有使用文件名。此网站将接受用户上传的mp3,然后为其制作块并播放。不可能输入文件名。您正在使用一个php变量来存储文件名$uplfile。那么,如果你这样做会发生什么:http://www.raphmond.com/modules/upload/attachments/Man 你让我开心。厉害。第一个解决方案是再次使用感谢。非常感谢。
<audio controls src="where-you-keep-your-uploaded-file"></audio>
<img alt="" onclick="music('http://www.my-website.org/media/myfile.mp3'); return false;" src="gfx/play.png">
<img alt="" onclick="pauseAudio(); return false;" src="gfx/pause.png">
<audio id="audioPlayer" src=""></audio>
function music(track){
$('#audioPlayer').attr('src', track);
$('#audioPlayer').attr('autoplay', 'autoplay');
$.get();
}
function pauseAudio(){
$('#audioPlayer').get(0).pause();
}