最近发现一个在网页中内嵌windows media player播放音频的问题,对于直接可以下载打开的音频url可以支持播放,对于网页存在跳转到音频的播放就力不从心了。
如下面的测试,在网页中嵌入播放器
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>
音乐器播放
</title>
</head>
<body>
<embed
style="width: 330px; height: 255px"
name=MediaPlayer1
pluginspage=http://www.microsoft.com/Windows/MediaPlayer
src="http://127.0.0.1/花心.mp3"
width=50 height=13
type=application/x-mplayer2
autostart="1"
showcontrols="1"
loop="1"
volume="50">
</embed>
</body>
</html>
这种情况是可以正常打开播放的。
然后写一个跳转脚本如下jump.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class testaspx : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Redirect("http://127.0.0.1/花心.mp3");
}
}
这时访问http://127.0.0.1/jump.aspx是可以跳转打开windows media player播放音频,但是如果将上面的播放页里面的音频地址改为"http://127.0.0.1/jump.aspx"则不能正常播放。
如果要做音频播放器,如果遇到资源存在内部跳转的情况,可以考虑放弃微软的播放器,很多flash播放器都能很好的解决这个问题,比如dewplayer播放器,可以考虑用flash播放器来替换windows media player