locked
Use background task to play audio triggered by Push Notification RRS feed

  • Question

  • Hi all,

    I want to play a custom sound file when a raw notification arrives. The sound file will depend on the content of the raw notification. I have implemented a background task, it is in the manifest and registered in my app etc. It works fine on the emulator. When I send the raw notification the audio plays.

    But on a real device it doesn't. By the way, I need this to play when my app is not running. So the background task does the work. Am I missing something? Why does it work in the emulator and not on the device? (media audio is turned on for the device etc.). I am playing the audio file (mp3) using BackgroundMediaPlayer.

    Any ideas?

    Thanks,

    Ciarán

    Thursday, September 18, 2014 10:18 AM

Answers

  • The reason I used Push Trigger-> Raw -> Audio Task  is that I missed a note in the Windows Phone 8.1 documentation on toasts which says that toasts can in fact be used to play custom audio simply by providing the right path to the resource.

    Works now.

    audio.SetAttribute("src", string.Format("ms-appx:///Resources/Raw/{0}", sound));

    • Marked as answer by ciaran_mac_hkc Thursday, September 18, 2014 1:14 PM
    Thursday, September 18, 2014 1:14 PM

All replies

  • The reason I used Push Trigger-> Raw -> Audio Task  is that I missed a note in the Windows Phone 8.1 documentation on toasts which says that toasts can in fact be used to play custom audio simply by providing the right path to the resource.

    Works now.

    audio.SetAttribute("src", string.Format("ms-appx:///Resources/Raw/{0}", sound));

    • Marked as answer by ciaran_mac_hkc Thursday, September 18, 2014 1:14 PM
    Thursday, September 18, 2014 1:14 PM
  • Hi ciaran_mac_hkc,

    I am very glad that you have solved your problem by yourself.
    If you have any other problem, welcome to post it in this forum.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 19, 2014 3:33 AM
    Moderator