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.

Re: How to get a URI of an On memory file. 80 80

You need to play it?!

Re: How to get a URI of an On memory file. 80 80

Yes, under SilverLight, I have A MediaElement

<MediaElement source = "The memory"/>
Re: How to get a URI of an On memory file. 80 80

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));
Re: How to get a URI of an On memory file. 80 80

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.

Re: How to get a URI of an On memory file. 80 80

You made me lost!!! <MediaElement source ="filePath"> it doesn't need anything from memory, I expected you need some binary representation to your file!!!!
http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.source.aspx

Re: How to get a URI of an On memory file. 80 80

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.

Re: How to get a URI of an On memory file. 80 80

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

Re: How to get a URI of an On memory file. 80 80

I also gave the solution!!! Back to 2nd reply!

Re: How to get a URI of an On memory file. 80 80

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.