Windows phone 7 播放声音时产生噪音windows phone 7 emulator

Windows phone 7 播放声音时产生噪音windows phone 7 emulator,windows-phone-7,audio,Windows Phone 7,Audio,我有一个.wav音乐文件。 当我尝试使用SoundEffect.play()播放时 mus1.Play();我听到的是噪音而不是音乐。 在PC音乐播放器中也能很好地播放。 如何解决这个问题 如何确保它在Windows Phone 7中也能正常播放?请尝试以下代码 MainPage.xaml.cs namespace MediaSample { public partial class MainPage : PhoneApplicationPage { // Con

我有一个.wav音乐文件。 当我尝试使用SoundEffect.play()播放时

mus1.Play();我听到的是噪音而不是音乐。 在PC音乐播放器中也能很好地播放。 如何解决这个问题

如何确保它在Windows Phone 7中也能正常播放?

请尝试以下代码

MainPage.xaml.cs

namespace MediaSample
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            progress.DataContext = this;
            this.Loaded += new System.Windows.RoutedEventHandler(MainPage_Loaded);
            mediaplayer.BufferingProgressChanged += new System.Windows.RoutedEventHandler(mediaplayer_BufferingProgressChanged);
            mediaplayer.CurrentStateChanged += new RoutedEventHandler(mediaplayer_CurrentStateChanged);
        }

        public double Duration { get; set; }

        void mediaplayer_CurrentStateChanged(object sender, RoutedEventArgs e)
        {
            if (mediaplayer.CurrentState == MediaElementState.Playing)
            {
                Duration = mediaplayer.NaturalDuration.TimeSpan.TotalSeconds;
                ThreadPool.QueueUserWorkItem(o =>
                {
                    while (true)
                    {
                        Dispatcher.BeginInvoke(new Action(() => Progress = mediaplayer.Position.TotalSeconds * 100 / Duration));
                        Thread.Sleep(0);
                    }
                });
            }
        }

        void mediaplayer_BufferingProgressChanged(object sender, System.Windows.RoutedEventArgs e)
        {
            MediaElement mediaplayer = sender as MediaElement;
            if (mediaplayer.BufferingProgress == 1)
                Debug.WriteLine(mediaplayer.NaturalDuration);
        }

        void MainPage_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            mediaplayer.Source = new Uri("/Oru nalum..mp3", UriKind.Relative);
            mediaplayer.Play();
        }



        public double Progress
        {
            get { return (double)GetValue(ProgressProperty); }
            set { SetValue(ProgressProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Progress.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ProgressProperty =
            DependencyProperty.Register("Progress", typeof(double), typeof(PhoneApplicationPage), new PropertyMetadata(0.0));



    }
}
MainPage.xaml

<phone:PhoneApplicationPage 
    x:Class="MediaSample.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="Media Application" Style="{StaticResource PhoneTextNormalStyle}"/>
        </StackPanel>        

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <MediaElement x:Name="mediaplayer"/>
            <ProgressBar Height="40"  x:Name="progress" Value="{Binding Path=Progress}"/>
        </Grid>
    </Grid>


</phone:PhoneApplicationPage>

添加Mp3文件如下:,

这样你就可以添加.wav文件了。工作很好。以上测试代码。
谢谢。

使用MeadiaElement而不是SoundEffect类。 试试这个
听起来.wav文件中有WP7不理解的内容。为什么不尝试将其转换为.wav(是的,我知道它已经在.wav中了),因为这可能会删除未知数据


厚颜无耻(http://audacity.sourceforge.net/)是免费的,我会为你做这件事。只需将.wav文件拖到其中,然后单击文件-->导出…

您可以发布一些代码让我们知道您尝试了什么吗?Francly,这似乎是emulator的一个问题。。。你不能找人来测试你的应用程序,看看问题出在哪里吗?如果您愿意,您可以在internet上发布一个XAP示例,我或其他开发人员一定会帮助您测试和检查物理设备中是否存在问题!我很抱歉重新点燃一个旧帖子,但我得到了同样的东西,不过简单地改为.WAV with Audacity并不能为我解决这个问题,你能帮我吗?(在实际设备上,我得到的是失真而不是人声音频)