c# - Storage file to System uri? -


i have windows metro app written in c#.

here code using pick file local music library:

fileopenpicker openpicker = new fileopenpicker(); openpicker.viewmode = pickerviewmode.thumbnail; openpicker.suggestedstartlocation = pickerlocationid.musiclibrary; openpicker.filetypefilter.add(".mp3"); openpicker.filetypefilter.add(".wav");  storagefile file = await openpicker.picksinglefileasync(); if (file != null) {    mymediaelement.source = file; //error here } else {     //error here } 

it says storagefile cannot converted system.uri used change source of mediaelement. how make file became uri link? seems uri("...") accepts string of file location is.

you have use file stream along setsource. how play local media file using mediaelement:

var file = await openpicker.picksinglefileasync(); var stream = await file.openasync(windows.storage.fileaccessmode.read); mymediaelement.setsource(stream, file.contenttype); 

Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -