1

I currently store text to speech mp3 files as varbinary(max) in the database. what I want to do is play those audio files using the embed tag where the source is ashx file that will recieve the id of the database record and write the byte array.

My ashx file has the following code

byte[] byteArray = ttsMessage.MessageContents;
context.Response.Buffer = true;
context.Response.Clear();
context.Response.ClearContent();
context.Response.ClearHeaders();
context.Response.ContentType = "audio/mpeg";
context.Response.OutputStream.Write(byteArray, 0, byteArray.Length); 
context.Response.End();

The call from the aspx page is as follows

Panel5.Controls.Add(new LiteralControl(String.Format("<embed src='/TestArea/PreviewWav.ashx?source={0}' type='audio/mpeg' height='60px' width='144px'/>", ttsMessage.Id.ToString())));

I have gotten this to work with the following

Panel5.Controls.Add(new LiteralControl(String.Format("<audio controls='controls' autoplay='autoplay'><source src='/TestArea/PreviewWav.ashx?source={0}' type='audio/x-wav' /></audio>", ttsMessage.Id.ToString())));

Using the audio tag but cannot seem to get it to work with the embed tag.

I am using IE9/VS2010 Any ideas?

user1111692
  • 31
  • 1
  • 3

1 Answers1

0

I think the wrong thing with embed tag is that... Embed tag call a plugin like winmediaplayer ocx than handler firstly called from web page than media plugin get the ashx url than it started to call handler. But web page's request and mediaplayer plugin's requests are diffent so if you check users Authentication or some other header information it fails.

You can easily see that on fiddler utility. On fiddler top-right side shows the request info. there is a user-agent part. Look it carefully. How many requests happen from your handler,notice them. What are the differs. for each reqs.

If you have this issue, You may use a ticket system or redirect a safety area for download without header or other request checks. Sadly web page requst cannot complately transfer media player and others.

hope helps

Davut Gürbüz
  • 5,526
  • 4
  • 47
  • 83