0

Hello,
How would I go about being able to use a URI of a binary class.
For example, I need to be able to give the URI for a song, but the song comes for a SQL server which sends it in a binary form, which is on the memory.

Thanks so much for any help.

3
Contributors
9
Replies
10
Views
8 Years
Discussion Span
Last Post by HBMSGuy
0

Yes, under SilverLight, I have A MediaElement

<MediaElement source = "The memory"/>
0

OK, I just asked you because I expected you need just to play a song from your application without interacting with Media Player or if you need to play a song file without any information about the software user uses.

So, to convert any file to its binary representative

System.IO.FileStream fs = new System.IO.FileStream(@"FilePath", System.IO.FileMode.Open);
byte[] fileAsBytes = new byte[fs.Length];
fs.Read(fileAsBytes, 0, fileAsBytes.Length);
fs.Close();

To convert it back to stream

System.IO.StreamReader sr =  new System.IO.StreamReader(new System.IO.MemoryStream(fileAsBytes));
0

Thanks,
I kinda see what you are getting at. The issue is that I have:
MediaElement.Source = (a URI)

That is what I can't think of is how to pass basically a class (on memory value), as a file path.
Thanks for the help thus far.

0

Yes, but now I am wondering if I did something wrong. I have a SQL server which sends it as binary. The issue is when I have the data I never have the file location. I just have the binary value it returned.

For example:
I query the server for a song.
It returns the song as binary.
I set the source of the media element to the value returned.

That thirds step is my issue.
Thanks for the help.

0

So this has nothing to do with files? You have a song stored as binary in the SQL Server and want to use MediaPlayer to play the song, but media player is asking for a URI and you only have a memory buffer?

Write out a temporary file..
http://silverlight.net/forums/t/94557.aspx
http://www.iis.net/extensions/SmoothStreaming

You have SQL Blob storage, effectively the same thing:
http://blogs.msdn.com/jnak/archive/2008/11/05/silverlight-mediaelement-playing-a-video-stored-in-windows-azure-blob-storage.aspx
http://timheuer.com/blog/archive/2008/05/06/streaming-media-in-silverlight.aspx

0

Thanks for your help, with what you gave me it was able to complete the MediaPlayer.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.