I have a StorageFile
instance in the foreground refers to a music file. I want to play it in the BackgroundAudioTask
but the problem is:
- I can't set the file in the foreground using
SetFileSource()
since as it is said:
make sure you define all objects to set their source in the background process only. The system will throw an InvalidCastException if your app tries to set a source other than a URI in the foreground process.
- I can't pass file path and then reload it from storage in the background using
StorageFile.GetFileFromPathAsync
because my app may not have access to it (a shared file from another app internal storage).
The Only solution comes to my mind is to pass the same StorageFile object to background, but don't know how to do it since they are on different threads.
So how to play a file in the background?
(It's a windows phone runtime app)