Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8451549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:16:17+00:00 2026-06-10T11:16:17+00:00

I have wpf prism application with some modules. One module has folder sounds and

  • 0

I have wpf prism application with some modules. One module has folder “sounds” and mysound.wav in it, wav file has “resource” value for build action (packed in result dll). I want to play this wav file, but i can’t create valid Uri for it.

Uri(@"pack://application:,,,/MyGame;component/sounds/mysound.wav")

not working.
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:16:19+00:00Added an answer on June 10, 2026 at 11:16 am
    • http://msdn.microsoft.com/en-EN/library/aa970069.aspx

    It says the “application” authority is for referring to content known at compile time (i.e. you have a reference to the assembly).

    Because you are using Prism and the modules are loaded dynamically maybe this implies that you can’t use “application” to refer to them…(but on the other hand it could mean if an assembly is loaded into an application, then “application” can resolve to items in that assembly).

    So if you mark your WAV file as “Content” instead, then the file will be loose, and you can use “siteoforigin” to access it (and maybe “application” depending on your intepretation of the microsoft link).

    Make sure you set “Copy to Output Directory” set to “Copy Always” or “Copy if newer” so that the WAV file is output to your Build directory.

    However, you don’t want “loose” files, so the search continues….


    MediaPlayer, MediaElement and MediaTimeline only allow the media “file” to be set via the .Source attribute …and that only takes a Uri.

    There isn’t any way of setting the “source” to come from a Stream…if there was then you could have had a method in your Prism module to look up/load a sound file by name and return it as a Stream.

    (you may not like to hear that Silverlight can load a media object from a Stream).


    Here are some other ideas for supplying the data of your WAV file that is embedded in your assembly/module to MediaElement, MediaPlayer or MediaTimeline:

    • Have your WAV files embedded in the module…but when you need to play them…you write the WAV content to a temporary files, and then you set up a Uri to point to that temporary file.

    • Try and use the Silverlight version of the MediaElement / MediaPlayer that can accept Streams, and write your module so that it uses Silverlight….there are various hacks around to host Silverlight in a WPF application….how well this would work I don’t know.

    • Register your own “protocol” that you can then use in a Uri.

      Use WebRequest.RegisterPrefix to register your protocol prefix, and
      supply it with a WebRequest factory i.e. something that implements
      IWebRequestCreate.

      Then create your own type of WebRequest by deriving from WebRequest
      …and get that factory to return instances of it….. your
      implementation would managed requesting the data from the Resource
      stream….which you can access via GetResourceStream and the .Stream
      property in the returned StreamResourceInfo.

      Then you could use something like e.g. new
      Uri(“loadwavfrom://mysound.wav”)

    • Perhaps use a PackageStore….add all your WAV files to the store as parts…and then get a Uri to the “Part” in that package and pass that as the .Source.

    • http://msdn.microsoft.com/en-us/library/3tf230ta

    • http://hackingsilverlight.blogspot.co.uk/2009/12/silverlight-hosting-in-wpf.html


    UPDATE:

    I tried RegisterPrefix and the PackageStore, and they didn’t allow it to work.

    See this post:

    • http://go4answers.webhost4life.com/Example/uri-netpipewhatever-unusable-62823.aspx

    Because MediaPlayer/MediaTimeline, etc uses Windows Media Player underneath,….when you consider Windows Media is a native app…it’s very doubtful that it can access a “Resource” from inside a .NET assembly.

    So by the looks of it, it doesn’t know how to access media except via local or HTTP based Uris.

    When you use an “application” pack URI that points to a “Content” file, this must get mapped to a local file URL when given to the Media Player underneath.

    So the possible workaround I can think of are:

    • keep the WAV files as “Resource”…but write out the data to temporary files as needed…and supply that temporary file as the Uri.

    • put the WAV files in your project as “Content”…and supply the right Uri to that file

    • write your own basic local HTTP server/or use IIS and “host” the WAV files … you can then use a HTTP based Url which to access the file. (a lot of hassle I know).

    • use a different media player control….one that either supports accessing a Resource in a .NET assembly….or allows you to provide a proxy where you supply the data to the player. You could look at http://vlcdotnet.codeplex.com/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF application using Prism. The application loads several modules. Each module
This relates to Composite Application Guidance for WPF, or Prism. I have one MainRegion
I have a Main WPF application and other modules and I am using PRISM
I have a WPF application that is written using MVVM Prism. It has a
I have a WPF Desktop application using Prism 4, in my bootstrapper i have
I have WPF Application where I have One main form and other user controls
I have an application which I am developing using WPF\Prism\MVVM. All is going well
I have an application all done in WPF, using MvvM/Prism/Unity and Remote as datasource.
I have an application written using Prism 4.0. It has lots of Views which
I'm looking for a WPF prism with ribbon application samples and tutorials. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.