0

我有一个应用程序可以播放用 HTML/JS 为 Windows 8 编写的互联网 mp3 流。

我希望它即使在应用程序处于后台时也能继续播放音频,但是它仍然无法正常工作。

我试过以下

  • 将 msAudioCategory="BackgroundCapableMedia" 添加到我的音频标签
  • 在声明中添加音频作为后台任务
  • 我已将 playpausetogglepressed、playpressed、stoppressed 和 pausepressed 事件监听器添加到媒体控件
    mediaControl = Windows.Media.MediaControl;

    // Add event listeners for PBM notifications to illustrate app is
    // getting a new SoundLevel and pass the audio tag along to the function

    mediaControl.addEventListener("soundlevelchanged", $scope.soundLevelChanged, false);

    // Add event listeners for the mandatory media commands.
    // These are necessary to play streams of type 'backgroundCapableMedia'
    mediaControl.addEventListener("playpausetogglepressed", $scope.playpause, false);
    mediaControl.addEventListener("playpressed", $scope.play, false);
    mediaControl.addEventListener("stoppressed", $scope.stop, false);
    mediaControl.addEventListener("pausepressed", $scope.pause, false);

我似乎仍然无法弄清楚我错过了什么。

4

0 回答 0