在Windows Phone 7的音效 [英] Sound effect in windows phone 7

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

问题描述

我想为从手机歌曲集播放音乐



是否在声音效果性能支持从打歌曲集



此前的我用媒体播放器播放的歌曲,但我想设置的音乐没有停顿,能够



代码音效:
SoundEffect中的效果;
SoundEffectInstance实例;

  =效果SoundEffect.FromStream(ml.Songs [songSelectedIndex]); 
实例= effect.CreateInstance();
instance.IsLooped = TRUE;
instance.Volume = 1.0F;
instance.Pitch = 1.0F;
instance.Play();



代码媒体库:

 使用(VAR毫升=新MediaLibrary())

{
FrameworkDispatcher.Update();
MediaPlayer.Play(ml.Songs [songSelectedIndex]);
MediaPlayer.IsRepeating = TRUE;
}


解决方案

A 歌曲是包含音乐流,只能用媒体播放器上播放的一类。你的代码是不工作的原因是因为的 FromStream 方法需要流是:





  • 的PCM波形文件

  • 单声道或立体声

  • 8位或16位

  • 介于8000赫兹48000赫兹的采样率




我没试过,也不知道是什么认证准则作出它,但你也许能够使音乐unpauseable与的MediaPlayer 。办理 MediaStateChanged 事件检查音乐暂停。如果是,则调用恢复< 。/ A>办法继续玩



编辑 - 更新的代码:



处理MediaStageChanged事件是相同的任何其他事件。

  MediaPlayer.MediaStateChanged + =新的EventHandler< EventArgs的>(MediaPlayer_MediaStateChanged); 

在事件处理程序,做到这一点:

 无效MediaPlayer_MediaStateChanged(对象发件人,EventArgs五)
{
如果(MediaPlayer.State == MediaState.Paused)MediaPlayer.Resume();
}


I am trying to play a music from the phone song collection.

Does the sound effect properties support playing from the song collection?

Previously i used the media player to play the song but i want to set the music to not pause-able.

Code for sound effect : SoundEffect effect; SoundEffectInstance instance;

        effect = SoundEffect.FromStream(ml.Songs[songSelectedIndex]);
        instance = effect.CreateInstance();
        instance.IsLooped = true;
        instance.Volume = 1.0f;
        instance.Pitch = 1.0f;
        instance.Play();

Code for media library :

        using (var ml = new MediaLibrary())

        {
            FrameworkDispatcher.Update();
            MediaPlayer.Play(ml.Songs[songSelectedIndex]);
            MediaPlayer.IsRepeating = true;
        }

解决方案

A Song is a class that contains the music stream and can only be played with the Media Player. The reason your code isn't working is because the FromStream method requires the stream to be:

  • A PCM wave file
  • Mono or stereo
  • 8 or 16 bit
  • Between 8,000 Hz and 48,000 Hz sample rate

I haven't tried this, nor know what the certification guidelines make of it, but you might be able to make the music unpauseable with the MediaPlayer. Handle the MediaStateChanged event and check if the music is paused. If it is, then call the Resume method to continue playing.

Edit - Update with code:

Handling the MediaStageChanged event is the same as any other event.

MediaPlayer.MediaStateChanged += new EventHandler<EventArgs>(MediaPlayer_MediaStateChanged);

In your event handler, do this:

void MediaPlayer_MediaStateChanged(object sender, EventArgs e)
{
    if (MediaPlayer.State == MediaState.Paused) MediaPlayer.Resume();
}

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

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