wpf - How can I specify MediaElement.Source with non-relative uri? -
we have wpf modules hosted in cpp unmanaged/managed application. enviroment causing troubles when specifying relative uri's media content. example, have no problem of doing in testapp:
<mediaelement grid.row="0" x:name="player" source="media\getting started with.wmv" loadedbehavior="manual" unloadedbehavior="stop" stretch="fill" mediaopened="element_mediaopened" mediaended="element_mediaended"/> but, mentioned, not work in production code.
if try use pack schema this:
source="pack://application:,,,/media/getting started with.wmv" i exception:
cannot navigate application resource 'pack://application:,,,/media/getting started with.wmw' using webbrowser control. uri navigation, resource must @ application�s site of origin. use pack://siteoforigin:,,,/ prefix avoid hard-coding uri. if try use 'siteoforigin' schema this:
source="pack://siteoforigin:,,,/media/getting started olga 7.wmv" i error:
application identity not set. the media file set "content" , "copy always".
how can specify mediaelement source using absolute uri in wpf desktop application?
i found solution (kinda). guessing relative url's can not resolved because main .exe cpp mfc application. in order create absolute uri's did this:
player.source = new uri(createabsolutepathto("media/getting started with.wmv"), urikind.absolute); private static string createabsolutepathto(string mediafile) { return path.combine(new fileinfo(assembly.getexecutingassembly().location).directoryname, mediafile); } i binding viewmodel logic wrapped property on viewmodel , source databound in xaml.
its working, not pretty be.
Comments
Post a Comment