I have an audio player that uses BackgroundAudioPlayer together with AudioPlayerAgent. Everything is working fine, except there's one use case I don't know how to handle.
If I play an audio track in my application and then the user switches to another application, the audio track continues to play in the background as it should - but I guess my application has now been swapped to memory and is suspended.
My question is: if the user now starts to play music in another app, I do get the AudioPlayerAgent.UserAction.Stop action as a callback to my AudioAgent. But can I do anything about this now from my app's point of view? I mean, I would like to save the position of the audio playback where the user was in my app, but my app has been suspended, right?
When my app is in the foreground and the audio stops, I do get the BackgroundAudioPlayer.Instance.PlayerState.Stopped event. It's here that I normally save the position of the playback. But if the user switches to another app to play music, I don't get this event.
So I am just wondering how to handle this kind of case. Is there anything I can do to improve the user experience?
The only way is to save that Position to Isolated Storage in the agent code.
See this very useful article of Paul about how to use Background audio agent and the way to communicate between UI and agent side
Related
I am trying to get Alexa to play an audio sound to a specific speaker group on a button press. I have a doorbell button which is hooked up to my Raspberry Pi. I can detect when the button is physically pressed on the Pi so from here I want to some how issue a command to Alexa to play an mp3 file to a pre-configured speaker group (everywhere). Is this possible?
The Pi has node-red and MQTT installed so REST Requests are no problem!
The simple answer is no. The interaction with Alexa is user initiative most of the time. That means, user starts a conversation and then Alexa speaks or plays an audio. The only times that Alexa wakes up on its own is when there is a reminder or a notification (Proactive Events API). The Proactive Events API allows you to send notifications to users of your skill. When your skill successfully sends a notification to a user’s Alexa device, the user hears a chime sound that indicates a notification has arrived. The user can then say, “Alexa, read my notifications” and hear the details.
So, for your use case, it is not possible to wake Alexa to play the mp3 file as result of pressing a button.
I'm trying to queue a song to Spotify Desktop (Windows 8.1) making use of Spotify Remote Control Bridge. I want that song to be appended after the current playing track.
Due to the restrictions Spotify applies to this API, there's no public documentation and I can't get in contact with their developers. This is one of the posts I've been following to understand how this API works: https://medium.com/#b3ngr33ni3r/hijacking-spotify-web-control-5014b0a1a360
I've successfully played a song with https://XXXX.spotilocal.com/remote/play.json?oauth=XXXX&csrf=XXXX&uri=XXXX, but it jumps to playing queue instantly and replaces it entirely.
When I call https://XXXX.spotilocal.com/remote/queue.json?oauth=XXXX&csrf=XXXX&uri=XXXX it always returns "Method not implemented". Do I need a special Oauth token? Or CSRF token?
Just giving an update, you can now add tracks to a queue via a BETA endpoint.
https://developer.spotify.com/documentation/web-api/reference/player/add-to-queue/
I've tested it, and it seems to work as expected.
queue.json endpoint
This endpoint appeared in their js-library, although it never worked and it's, like you said, not implemented. It doesn't matter which arguments you supply.
play.json endpoint
So, this endpoint is more interesting. First of all, in the past you could use the following parameter ?action=queue to add a song to the queue, but sadly this doesn't work with the latest versions for whatever reason. The only thing you currently can supply is the play-context ?context. A context basically tells spotify what to play next (like setting a new queue). So if you want to play a track of an album and simultaneously want the album to finish after the specific song ends, you can supply a ?context=spotify:album:albumid. There is some more information about it in this issue of my library.
Summarizing, you currently can't add songs to the spotify queue, but add your own context which will be used as a future queue
Although it would be nice to know why spotify isn't releasing any documentation about the local-API.
assume I have a tile on my Microsoft Band (2) and want to record the current HB when the user presses my tile (or a button on a screen).
Just something like cortana does - trigger anything on the band - cortana is started on the device handling the request.
I found nothing about such a scenario in the (poor) SDK documentation.
Is such a solution possible - or do I always have to have my app in foreground on the phone (WP10)?
In order to be notified of Tile events (such as button presses), your application must (1) be running in the foreground or background, (2) have an outstanding connection to the Band, and (3) be subscribed to those specific events. There is currently no way (on Windows) to otherwise notify an application of input from the Band.
I have created an app that triggers video at particular time similar to alarm, but the problem I am facing is that when I am out of application & have set the timings the video doesn't show up(i.e. similar to alarm I should get notification out side my app). Please help me out with the same. Would be very grateful for any helpful suggestion.
When an application is not running, you cannot predict what time its background process will execute, so there is no way that you can set an alarm with any degree of precision smaller than perhaps an hour. The only way to have timing close to accurate would be with a push notification from a server. Even then, the notification you receive will not be able to open and play video on its own. You could create a push/toast notification that originates at a server, sends the user a toast, the user taps it, and that opens the app to play the video. You can't do it without user intervention.
See this link for an overview, including the constraints on background agents: http://msdn.microsoft.com/en-us/library/hh202942(v=VS.92).aspx
You cannot open an app and play a video from a background agent. You can show a toast notification that would allow the user to open the app. You can use a Scheduled Agent or PeriodicTask.You can then use the ShellToast to show a toast notification so the user can open the app. Once the app is open you can start the video.
So, Ive made Windows Phone app that contains rss-feeds. I would now like to add the possibility for toasts to popup when a stream is updated. Ive read up on how to use Toasts to notify the user, but how can i make my rss-reader periodically poll the rss-feeds for the latests news when the app is suspended in the background. Example code would be highly appriciated!
Check the "Background Agent Sample" Windows Phone Code Samples to see how you can create a periodic background agent, that will allow you to pool the rss feed(s) and show a toast notification to the user!