2

I've developed an audio player that use decoder library, so now I don't know how to make it can run in background. I've read 'background audio overview for windows phone' but it is for system player default. so how can do this for my own audio player? any solution?

Thanks!

lemta
  • 211
  • 3
  • 8

1 Answers1

1

First, the “background audio overview for windows phone” is about the wrong platform. It’s about the Silverlight. If you want the WP8.1-WinRT platform, here’s the correct overview article.

Second, yes, you can’t have your own audio player because it’s too deeply integrated in the OS (by that I mean universal volume control, pause on call, etc). You can implement your own custom decoder. You’ll need to read media samples from wherever you want, and feed them, when asked, to the OS-implemented media pipeline, in any format the OS understands. If you are developing something like FLAC player, you’ll probably want to provide uncompressed PCM samples.

If you’re targeting WinRT platform, you’ll need to code some C++/CX to develop a COM object that implements IMFMediaSource interface. And another one that implements IMediaSource and IMFGetService interfaces, and creates an instance of your IMFMediaSource object.

If you’ll target Silverlight instead, you’ll be able to develop your app in pure C#, by implementing a MediaStreamSource. If you’re going to stream your audio asynchronously from the network, C# approach should be easier due to async-await feature.

Soonts
  • 20,079
  • 9
  • 57
  • 130
  • Hi Soonts, Actually, I want to make some sound effects such as equalizer, echo... to player and I think best method is catch PCM samples in media pipeline then apply effect before it output to sound card , but I don't know how to implement this with OS's media pipeline – lemta Sep 14 '15 at 02:17
  • It’s relatively easy on desktop by building a custom MF topology that will include your custom MF transform. I don’t think custom topologies are implemented for Store/Phone apps. You might be able to emulate. On the reader end, implement a custom MF media sink that will receive uncompressed samples from the pipeline. On the writer end, implement a custom media source that will feed samples to the renderer pipeline. Manually transfer those samples between the two. Do not forget about the attributes. You will have the most fun implementing pause and seek functionality. – Soonts Sep 14 '15 at 03:10
  • Beware of two things. (1) On phones, your app may waste electricity compared to the native player. Normally, media decoders implemented by the DSP part of the SoC, very power efficient. (2) The task is hard, it once took me about 2-3 weeks fulltime to implement an MF source. It played both video and audio; audio only should be easier, but only slightly. – Soonts Sep 14 '15 at 03:10