1

Have MediaElement in my application used to preview media file such as music, video, image.. MediaElement only allow set source is a URi(contain file path). I have image storaged by Byte array and now I want preview it on MediaElement. how to I convert from byte array to uri to preview mediafile ? If have any other solution to preview mediafie, Please list it. Thank.!

Snowbear
  • 16,924
  • 3
  • 43
  • 67
Tuan Bach Van
  • 164
  • 2
  • 7

2 Answers2

1

if it is path...then you can use System.Text.Encoding.UTF8.GetString(byteArray[])

and then assign that path to media element to preview image...

If it is image, you have to convert back that image from byte and then assign it ti Image element...to preview. Check this link: http://www.codeproject.com/KB/recipes/ImageConverter.aspx

Ovais Khatri
  • 3,201
  • 16
  • 14
0

You can do it through a MemoryStream. See example here.

Community
  • 1
  • 1
Vlad
  • 35,022
  • 6
  • 77
  • 199