在 WP7 上,我可以播放库中的歌曲,用 mp3 音频中断它,然后恢复播放吗?

发布于 2024-11-08 00:40:46 字数 818 浏览 4 评论 0原文

我想要实现的是:

  1. 从媒体库播放背景音乐
  2. 在某个触发器上,淡出音乐,播放另一个mp3文件(不同长度,秒到一分钟)
  3. 播放该音频后,恢复上一个库中的音乐

现在我遇到了这些限制:

  • 为了访问和播放用户库中的音乐,我需要使用 MediaPlayer XNA 类。
  • 为了播放任意 mp3 文件,我需要使用 MediaPlayer 或 MediaElement,但不需要使用 SoundEffect 或 SoundEffectInstance
  • 如果我使用 MediaElement 播放任何内容,MediaPlayer 就会停止。它完全丢失了音频队列,所以我需要播放剩余的音乐,这没问题,但
  • MediaPlayer 不支持搜索,所以我无法打开上一首歌曲,只能转到暂停之前的位置

所以:

  • 我不想要要使用 SoundEffect 或 SoundEffectInstance,因为音频必须是 wav 文件。
  • 我不能只使用 MediaPlayer,因为如果我在那里播放音频来中断歌曲,我将无法找到其之前的位置
  • 我无法使用 MediaPlayer 和 MediaElement 的组合,因为 MediaPlayer 会停止 MediaPlayer,这再次阻止了我从恢复之前的播放开始,
  • 我不能只使用 MediaElement,因为它无法播放库中的歌曲。

您是否看到我错过的任何内容,或者这实际上是我必须吸收它并使用 wav 文件的唯一选择? (其中很多都是即时下载的,这种方式显然效率很低!)有什么建议吗?

谢谢!

what I want to achieve is this:

  1. Play background music from the media library
  2. On a certain trigger, fade out the music, play another mp3 file (of various lengths, seconds up to a minute)
  3. After that piece of audio is played, resume previous music from the library

Now I run into these constraints:

  • In order to access and play music from the user's library, I need to use the MediaPlayer XNA class.
  • In order to play an arbitrary mp3 file, I need to use either MediaPlayer or MediaElement, but not SoundEffect or SoundEffectInstance
  • If I play anything using the MediaElement, MediaPlayer stops. It completely loses the audio queue so I would need to play the remaining music which would be ok BUT
  • MediaPlayer doesn't support seek so I cannot open the previous song and just go the the position before it got paused

So:

  • I don't want to use SoundEffect or SoundEffectInstance as the audio would have to be wav files.
  • I can't use just MediaPlayer because if I played the audio there to interrupt the song I wouldn't be able to seek to its previous position
  • I can't use the combination of MediaPlayer and MediaElement as MediaPlayer stops the MediaPlayer which again prevents me from resuming previous playback
  • I can't just use MediaElement because it can't play songs from the library

Do you see anything I missed or is really the only option I have to suck it up and use wav files? (There would be many of these downloaded on the fly and it is just plainly inefficient this way!) Any suggestions?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

紫轩蝶泪 2024-11-15 00:40:46

不幸的是,您遇到了平台的限制。

除了您已经确定的替代方案之外,您还可以通过 MediaElement 播放从外部源流式传输的音乐。通过使用计时器来跟踪播放了多少内容,当恢复曲目时,通过在对流媒体服务器的请求中包含起点来从曲目开始。这当然意味着您需要提供或找到合适的流媒体功能。 :(

这些都不是理想的,但目前这是我们拥有的最好的。Mango 中的背景音频设施可能会有所帮助,但在细节公布之前我们不能确定。

Unfortunately you've hit a limitation of the platform.

In addition to the alternative you've identified you could play the music streamed from an external source through a MediaElement. By using a timer to keep track of how much has played, when resuming the track start that far through the track by including the start point in your request to the streaming server. This does of course mean you need to provide or find a suitable streaming capability. :(

Neither of these are ideal but for now that's the best we have. The background audio facilites coming in Mango may help but until details are announced we can't say for sure.

小姐丶请自重 2024-11-15 00:40:46

不能只使用 MediaPlayer,因为如果我在那里播放音频来中断歌曲,我将无法找到其之前的位置。

您将使用 MediaPlayer 获得 mediastatechanged 事件,在这种情况下,您可以检查媒体播放器的状态并暂停歌曲,然后您也可以恢复歌曲

can't use just MediaPlayer because if I played the audio there to interrupt the song I wouldn't be able to seek to its previous position

You will get mediastatechanged event using MediaPlayer and inthat event you could check the state of the mediaplayer and Pause the Song and then you could also Resume the song

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文