示例#1
0
        public void Play()
        {
            if (this._player == null)
            {
                return;
            }

            Sound.Enqueue(_player.Start);
        }
示例#2
0
文件: Sound.cs 项目: noelb/monogame
        public static Sound Create(string assetPath, float volume, bool looping)
        {
            MediaPlayer player = new MediaPlayer();
            Sound       sound  = new Sound(player);

            player.SetDataSource(Game.contextInstance.Assets.OpenFd(assetPath).FileDescriptor);
            player.Prepared += sound.OnPrepared;
            sound.Looping    = looping;
            sound.Volume     = volume;

            Sound.Enqueue(player.Prepare);

            return(sound);
        }
示例#3
0
        public static Sound Create(string assetPath, float volume, bool looping)
        {
            MediaPlayer player = new MediaPlayer();
            Sound       sound  = new Sound(player);

            //This breaks the platformer sample. Not sure if it works anywhere else
            //player.SetDataSource(Game.contextInstance.Assets.OpenFd(assetPath).FileDescriptor);
            player.SetDataSource(assetPath);
            player.Prepared += sound.OnPrepared;
            sound.Looping    = looping;
            sound.Volume     = volume;

            Sound.Enqueue(player.Prepare);

            return(sound);
        }
示例#4
0
        public void Play()
        {
            Sound.Enqueue(() =>
            {
                lock (Sound.Map)
                {
                    if (this.Stream == null)
                    {
                        return;
                    }

                    AudioStream.Play(this.Stream);
                }
            }
                          );
        }
示例#5
0
        public static Sound Create(string url, float volume, bool looping)
        {
            Sound sound = null;

            AudioStream *pStream;

            lock (Sound.Map)
            {
                pStream = AudioStream.AllocateStream();

                sound = new Sound(pStream);
                Sound.Map[(IntPtr)pStream] = sound;
            }

            sound.Looping = looping;

            Sound.Enqueue(() => AudioStream.Create(pStream, url));

            sound.Volume = volume;

            return(sound);
        }