lemta
lemta

Reputation: 211

How to make audio player that written my own can run in background (Windows Phone 8.1- WinRT)?

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!

Upvotes: 2

Views: 185

Answers (1)

Soonts
Soonts

Reputation: 21936

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.

Upvotes: 1

Related Questions