首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试使用XNA播放声音效果

尝试使用XNA播放声音效果
EN

Stack Overflow用户
提问于 2013-03-18 00:39:37
回答 1查看 1.1K关注 0票数 0

我正在使用XNa的soundeffect对象为windows phone编写我的第一个应用程序,这将是一个声板。

该项目是Windows phone Silverlight和Xna应用程序c#

我从书中得到了一些示例代码,101 phone 7应用程序。要在声音中加载的linbe给我一个“类型StreamResourceInfo名称空间无法找到”

StreamResourceInfo info =Application.GetResourceStream(新Uri(“Audio/Cobbel.wav”,UriKind.Relative));

代码

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Xna.Framework.Audio;


namespace SlXnaApp4
{
public partial class MainPage : PhoneApplicationPage
{
    SoundEffect cowbell;

    // Constructor
    public MainPage()
    {
        // Load sound file

        StreamResourceInfo info = Application.GetResourceStream(new Uri("Audio/cowbell.wav", UriKind.Relative));

        // create xna sound
        cowbell = SoundEffect.FromStream(info);

        // Sub to per frame call back
        CompositionTarget.Rendering += CompositionTarget_Rendering;

        // requred for xna sound effects to work
        Microsoft.Xna.Framework.FrameworkDispatcher.Update();

        // testb sound
        cowbell.Play();

        InitializeComponent();
    }

    void CompositionTarget_Rendering(object sender, EventArgs e)
    {
        Microsoft.Xna.Framework.FrameworkDispatcher.Update();
    }




    // Simple button Click event handler to take us to the second page
    private void Button_Click(object sender, RoutedEventArgs e)
    {
        NavigationService.Navigate(new Uri("/GamePage.xaml", UriKind.Relative));
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {

    }
}

}

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-18 08:29:22

System.Windows.Resources添加using指令

代码语言:javascript
复制
using System.Windows.Resources;
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15463299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档