Custom Extension

G

Guest

I have a small web application that will create a an M3U playlist. I have
done all the work and can generate the required format and have set the
proper MIME type. However I have run into a small problem with WMP. If I
load the file (M3U.aspx?custom=blahblah) the player will play just fine, but
will not display each item in the playlist. I think that is because WMP is
confused because even though the content and MIME type say that it is an M3U
file the extension says ASPX.

So, how would I go about telling my server to process the my M3U.m3u file as
if it were aspx. I have added .m3u in the server configuration for my
website, but I must be missing something else.

I am using v1.1 and Windows Server 2003 Standard.
 
M

mark.brito

You really should generate a static M3U for scalability, precalculation
and caching reasons.

Checkout my media streaming portal demo at

http://www.wanfear.com/~mbrito/Content/HTML/MediaStreaming.html

This routine was originally written to create M3U's from MP3's with
Database tracking of Content, but I extended it to support any content
type such as Video, Pictures, Music, Products for Sale, Streaming
Music, Software, etc.

Heres a paste:

protected void UploadStreamingContent_Click(object sender,
System.EventArgs e)
{
this.adptrMusic.InsertCommand.Parameters["artist"].Value=this.txtName.Text;
this.adptrMusic.InsertCommand.Parameters["email"].Value=this.txtEmail.Text;
this.adptrMusic.InsertCommand.Parameters["message"].Value=this.txtMessage.Text;
this.adptrMusic.InsertCommand.Parameters["title"].Value=this.txtTitle.Text;
this.adptrMusic.InsertCommand.Parameters["featured"].Value=this.chkMusicFeatured.Checked;
string contentfilename=this.fileSong.Value;
string picturefilename = this.filePicture.Value;
if (contentfilename == null ||
contentfilename.Trim().Length == 0)
contentfilename = picturefilename;
// filename
if (contentfilename.LastIndexOf("\\") > 0)
{
contentfilename =
contentfilename.Substring(contentfilename.LastIndexOf("\\") + 1);
}
Regex regex = new Regex("[^A-Za-z1-9\\.]");
contentfilename = regex.Replace(contentfilename, "-");

if (picturefilename.LastIndexOf("\\") > 0)
{
picturefilename =
picturefilename.Substring(picturefilename.LastIndexOf("\\") + 1);
}
if (contentfilename.ToUpper().EndsWith("MP3"))
{
string m3ufilename = contentfilename.Substring(0,
contentfilename.LastIndexOf(".") + 1) + "m3u";
string m3ufqfn =
this.Request.MapPath(this.Request.ApplicationPath) + "\\Music\\" +
m3ufilename;
string mp3url =
ConfigurationSettings.AppSettings["MusicURLPrefix"].ToString() +
contentfilename;
if (File.Exists(m3ufqfn))
{
File.Delete(m3ufqfn);
}
FileStream fs = File.Create(m3ufqfn, 1024);
Byte[] info = new UTF8Encoding(true).GetBytes(mp3url);
fs.Write(info, 0, info.Length);
fs.Close();
contentfilename= m3ufilename;
}
string
pf=this.Request.MapPath(this.Request.ApplicationPath)+
"\\Pictures\\"+picturefilename;
if(File.Exists(pf))
File.Delete(pf);
this.filePicture.PostedFile.SaveAs(this.Request.MapPath(this.Request.ApplicationPath)+
"\\Pictures\\"+picturefilename);
pf=this.Request.MapPath(this.Request.ApplicationPath)+
"\\Music\\"+contentfilename;
if(File.Exists(pf))
File.Delete(pf);

this.fileSong.PostedFile.SaveAs(this.Request.MapPath(this.Request.ApplicationPath)+
"\\Music\\"+contentfilename);

this.adptrMusic.InsertCommand.Parameters["contentfilename"].Value=contentfilename;
this.adptrMusic.InsertCommand.Parameters["picturefilename"].Value=picturefilename;
this.adptrMusic.InsertCommand.Connection.Open();
this.adptrMusic.InsertCommand.ExecuteNonQuery();
this.adptrMusic.Fill(this.dsMusic.Tables["Content"]);
this.dgSongs.DataBind();
this.txtName.Text=string.Empty;
//this.txtEmail.Text=string.Empty;
this.txtMessage.Text=string.Empty;
this.txtTitle.Text=string.Empty;
this.lblSongAdded.Visible=true;
this.chkMusicFeatured.Checked=false;
}

Regards,
Mark B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top