locked
Play sound in Background on Timer Set RRS feed

  • Question

  • In my app I want to play sounds after setting the timer from my TimerPage where I put the Time after which selected sound should be played. Iwant to play the selected sound even if my application is closed. Howcan I do that ?
    Wednesday, July 11, 2012 7:04 PM

All replies

  • Iwant to play the selected sound even if my application is closed. Howcan I do that ?

    You can use the Alarm class to play a sound, and show a message, at a given time as long as the Sound file is included as Content of your XAP file.

    see also: Alarms and Reminders Overview for WIndows Phone
    Wednesday, July 11, 2012 7:47 PM
  • thanks for reply Eric..
    Is there a way to customize Alarm Dialog box and how can we handle the Snooze and Dismiss event from Code.?
    Wednesday, July 11, 2012 9:57 PM
  • Is there a way to customize Alarm Dialog box and how can we handle the Snooze and Dismiss event from Code.?
    Customization is very limited... An application can only customize the Sound and Content (i.e. the text displayed inside the dialog).
      Unfortunately, there is no mechanism for overriding the behavior of the Snooze or Dismiss buttons.
    Thursday, July 12, 2012 2:18 PM
  • Can there be another approach to accomplish this Task. 

    Just want to share my thoughts: 

    Can we run a Background Service which gets activated as I select the sound and set the time from Timer Page. Even my app is closed, this Background service loads my Timer Page after the time set previously and plays the selected sound and background service gets stop.

    Just to want to ask:

    1)How can I run Background Service with specified Time Interval on application close also? Isit valid in context with Windows Phone 7 certification requirement?

    2)How can we load page and play the sound as Background Service completes time.

    Sorry I am new to the Windows Phone Development.

    Friday, July 13, 2012 6:24 AM
  • 1) No, you cannot specify a time at which a ScheduledTask will run.  The system determines when a ScheduledTask runs based on various factors.
        See: Background Agents Overview for Windows Phone
        (FYI: Alarms and Reminders are the only background tasks that can be set to trigger at a specific time.)

    2) A background task cannot launch an app directly, although it can show a ShellToast which the user can then tap to launch the application.

    Friday, July 13, 2012 5:35 PM
  • Thanks for quick reply Erik..... Can u suggest me a workaround for this problem..??
    Friday, July 13, 2012 8:18 PM
  • Using Alarm class is the closest feature to what you want.

    Anything else that I can think of would not be reliable enough. (... and probably wouldn't pass certification.)
    (ex: using Background Audio to play a file with 'n' seconds of silence followed by the sound you want.)
    Friday, July 13, 2012 8:42 PM