在 Windows 7 Phone 中播放音频文件 [英] Play an audio file in Windows 7 Phone

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

问题描述

我正在 Silverlight 中进行基于 Windows 7 的应用程序开发.我无法找到以编程方式在 Windows 7 手机中播放音频文件的方法.过去几天我一直在谷歌上搜索它,但我找不到任何解决方案.C# 中有一个 SoundPlayer 类,但我想它在 Windows 7 Phone 中不可用.有人可以帮忙吗?

I am working on Windows 7 based application development in Silverlight. I have not been able to find a way to play a an audio file in windows 7 phone programmatically. I have been googling it since past few days but i could not get any solution of that. There is a class SoundPlayer in C# but i guess its not available in Windows 7 Phone. Can anyone please help?

推荐答案

使用 Xna 播放声音.您可以从 Silverlight 应用程序交叉引用 Xna,但要播放声音文件,您需要执行以下操作:

Use Xna to play the sound. You can cross reference Xna from a Silverlight app though, for playing a sound file, you need to the following:

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio
// ...
Stream stream = TitleContainer.OpenStream("sounds/bonk.wav");
SoundEffect effect = SoundEffect.FromStream(stream);
FrameworkDispatcher.Update();
effect.Play();

祝您的应用程序开发一切顺利!

All the best for your application development!

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

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