Detect application launch from Universal Volume Co

2019-04-10 00:53发布

问题:

I have an application, targeting mango devices, which plays music via a BackgroundAudioAgent. As such it integrates with the universal volume control (UVC).

Is there a way to detect when the application is launched by tapping the artists details in the UVC?

Alternatively, is there a way to set a deep link for the UVC to use?

I want this so that I can take the user to the "Now playing" page, rather than the main page, when the app is launched via the UVC.

Update
This also affects launching the app from the now playing tile in the Music & Video hub as the BackgroundAudioPlayer automatically integrates with this part of the hub.

回答1:

Using MediaHistory Zune Hub integration solves this problem. It also passes the Marketplace Test Kit capability test step in the RC SDK, so that’s a good sign.

If you start from the example on MSDN, calling the following code from GetNextTrack() and GetPreviousTrack() in the background audio agent means that when you click UVC or Zune Now Playing you can get back the navigation query string you specify here…

    private AudioTrack ChangeTrack()
    {
        AudioTrack track = _playList[currentTrackNumber];

        IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
        Stream s = isoStore.OpenFile("ApplicationIcon.png", FileMode.Open);

        MediaHistoryItem nowPlaying = new MediaHistoryItem();
        nowPlaying.Title = "Background Audio is playing!";
        nowPlaying.ImageStream = s;
        nowPlaying.PlayerContext.Add("keyString", track.Title);
        MediaHistory.Instance.NowPlaying = nowPlaying;

        return track;
    }