在 Windows Phone 8 中同时播放两个音频文件的最佳方式 [英] Best way to play two audio files simultaneously in Windows Phone 8

查看:25
本文介绍了在 Windows Phone 8 中同时播放两个音频文件的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前正在研究如何在 Windows Phone 8 中同时播放两个 mp3 或 aac 格式的文件.

Currently looking into how I can go about playing two mp3 or aac format files at the same time in Windows Phone 8.

目前我正在使用 XNA SoundEffect 类,但它只允许 WAV 文件,这不适合通过网络传输.

At the moment I am using the XNA SoundEffect class but that only allows WAV files which is not ideal for transferring over a network.

在研究时,我遇到了 SharpDX,但它似乎主要用于 .WAV 或一次播放一个文件.

While researching I ran into SharpDX but that appears to mainly be catered to .WAV or playing one file at a time.

我也发现了这个问题:在 Windows 8 Metro 应用程序中同时播放两种声音(C#/XAML)Windows 8 中可能有多种媒体元素,但我不确定它们是否在 Windows Phone 中(这个问题似乎不同意)

I also discovered this question: play two sounds simultaneously in Windows 8 Metro App (C#/XAML) Multiple media elements are possible in Windows 8 but I'm not sure if they are in Windows Phone (this question seems to disagree)

任何想法将不胜感激.

更新:我认为它不能通过 MediaElement 完成 http://msdn.microsoft.com/en-us/library/windowsphone/design/hh202883(v=vs.105).aspx

UPDATE: It can't be done through MediaElement as I thought http://msdn.microsoft.com/en-us/library/windowsphone/design/hh202883(v=vs.105).aspx

推荐答案

您可以尝试通过 MediaFoundation.MediaEngine(请参阅Windows Phone 8 支持的 Microsoft Media Foundation API" 以获取有关如何在 WP8 上正确初始化的指南).在 SharpDX 中有一个 Win8 示例 MediaPlayerApp 可以用作仅播放音频的起点(删除所有 d3d 部分并应用 WP8 指南).MonoGame中也有它的用法 MediaPlayer 班级.

You could try to do it through MediaFoundation.MediaEngine (see "Supported Microsoft Media Foundation APIs for Windows Phone 8" for guidelines on how to initialize it correctly on WP8). In SharpDX there is a Win8 samples MediaPlayerApp that could be used as a starting point to play only audio (remove all the d3d part and apply guidelines for WP8). There is also a usage of it in MonoGame MediaPlayer class.

关于同时使用SharpDX播放多个WAV,XAudio2完全可以,而SharpDX对XAudio2没有任何限制.

Concerning playing multiple WAV with SharpDX at the same time, it is perfectly possible with XAudio2, and SharpDX doesn't have any limitation concerning XAudio2.

WP8 CLR Garbarge 收集器只有一个巨大的担忧,它在收集时似乎会阻塞所有本机线程,包括像 XAudio2 这样的本机音频线程,这可能会导致音频卡顿.我们对此无能为力,因为这是操作系统和 .NET 线程调度的问题.

There is only a huge concern about the WP8 CLR Garbarge collector that seems to block all native threads when it is collecting, including native audio threads like XAudio2, and that could cause audio stuttering. There is nothing we can do about this, as this is an issue with the OS and the scheduling of threads with .NET.

我也对 WP8 实时解码两个 MP3 的能力有些怀疑...如果您有一些结果,请告诉我们.

I have also some doubt about the ability of WP8 to decode two MP3 in realtime... Let us know if you have some results.

这篇关于在 Windows Phone 8 中同时播放两个音频文件的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆