Ejemplo n.º 1
0
        private void pause_Click(object sender, System.EventArgs e)
        {
            bool paused = false;

            if (channel != null)
            {
                channel.getPaused(ref paused);
                channel.setPaused(!paused);
            }
        }
Ejemplo n.º 2
0
        private void pause_Click(object sender, System.EventArgs e)
        {
            FMOD.RESULT result;

            bool paused = false;

            result = channel.getPaused(ref paused);
            ERRCHECK(result);
            result = channel.setPaused(!paused);
            ERRCHECK(result);
        }
Ejemplo n.º 3
0
        internal bool IsChannelPlaying(FMOD.Channel channel)
        {
            if (channel == null)
            {
                return(false);
            }

            bool playing = false;
            bool paused  = false;

            FMOD.RESULT result = channel.isPlaying(ref playing);

            if (result != FMOD.RESULT.OK)
            {
                return(false);
            }

            if (playing == false)
            {
                return(playing);
            }

            if (channel.getPaused(ref paused) == FMOD.RESULT.OK)
            {
                return(!paused);
            }

            channel = null;
            return(false);
        }
        public bool IsSongPlaying()
        {
            bool isPlaying = false;

            Channel.getPaused(out isPlaying);
            return(!isPlaying);
        }
Ejemplo n.º 5
0
        //Use this to pause or resume sound
        public void PauseResume()
        {
            bool isPaused;

            _channel.getPaused(out isPaused);
            _channel.setPaused(!isPaused);
        }
Ejemplo n.º 6
0
        public static bool IsPaused()
        {
            bool paused = false;

            if (SoundEngine.IsPlaying())
            {
                FMODChannel.getPaused(ref paused);
            }

            return(paused);
        }
Ejemplo n.º 7
0
        public static bool IsSongPlaying()
        {
            if (CurrentSong == null)
            {
                return(false);
            }

            bool isPlaying = false;

            Channel.getPaused(out isPlaying);
            return(!isPlaying);
        }
Ejemplo n.º 8
0
        private void timer_Tick(object sender, System.EventArgs e)
        {
            FMOD.RESULT result;
            uint        ms              = 0;
            uint        lenms           = 0;
            bool        paused          = false;
            bool        playing         = false;
            int         channelsplaying = 0;

            if (channel != null)
            {
                FMOD.Sound currentsound = null;

                result = channel.isPlaying(ref playing);
                if ((result != FMOD.RESULT.OK) && (result != FMOD.RESULT.ERR_INVALID_HANDLE) && (result != FMOD.RESULT.ERR_CHANNEL_STOLEN))
                {
                    ERRCHECK(result);
                }

                result = channel.getPaused(ref paused);
                if ((result != FMOD.RESULT.OK) && (result != FMOD.RESULT.ERR_INVALID_HANDLE) && (result != FMOD.RESULT.ERR_CHANNEL_STOLEN))
                {
                    ERRCHECK(result);
                }

                result = channel.getPosition(ref ms, FMOD.TIMEUNIT.MS);
                if ((result != FMOD.RESULT.OK) && (result != FMOD.RESULT.ERR_INVALID_HANDLE) && (result != FMOD.RESULT.ERR_CHANNEL_STOLEN))
                {
                    ERRCHECK(result);
                }

                channel.getCurrentSound(ref currentsound);
                if (currentsound != null)
                {
                    result = currentsound.getLength(ref lenms, FMOD.TIMEUNIT.MS);
                    if ((result != FMOD.RESULT.OK) && (result != FMOD.RESULT.ERR_INVALID_HANDLE) && (result != FMOD.RESULT.ERR_CHANNEL_STOLEN))
                    {
                        ERRCHECK(result);
                    }
                }

                system.getChannelsPlaying(ref channelsplaying);
            }

            statusBar.Text = "Time " + (ms / 1000 / 60) + ":" + (ms / 1000 % 60) + ":" + (ms / 10 % 100) + "/" + (lenms / 1000 / 60) + ":" + (lenms / 1000 % 60) + ":" + (lenms / 10 % 100) + " " + (paused ? "Paused " : playing ? "Playing" : "Stopped") + " Channels Playing " + channelsplaying;

            if (system != null)
            {
                system.update();
            }
        }
Ejemplo n.º 9
0
 //float fTicking = 0;
 public override void Tick(float fElapsedTime, Vector3?vListenerPos)
 {
     base.Tick(fElapsedTime, vListenerPos);
     if (this.文件已载入 && m_FMODChannel != null)
     {
         m_FMODChannel.getMute(ref m_bMuted);
         //m_FMODChannel.getVolume(ref m_fVolumeMult);
         m_FMODChannel.getPaused(ref m_bPaused);
         m_FMODChannel.isPlaying(ref m_bPlaying);
         //fTicking += fElapsedTime;
     }
     //if (fTicking > 1.0F)
     //{
     //    fTicking = 0;
     //    string msg = String.Format("GM:{0},M:{1},GV:{2},V:{3}/{4}/{5},U:{6},P:{7}",
     //        m_HostPlayer.静音, m_bMuted, m_HostPlayer.音量倍率, m_fVolumeMult, m_fVolumeAttuMult, m_fVolumeMutedMult, m_bPaused, m_bPlaying);
     //    Framework.Log.ApplicationLogSink.Write("Sound:" + msg);
     //}
 }
Ejemplo n.º 10
0
        private void pauseButton_Click(object sender, System.EventArgs e)
        {
            if (channel != null)
            {
                bool ispaused = false;

                channel.getPaused(ref ispaused);
                channel.setPaused(!ispaused);

                if (ispaused)
                {
                    pauseButton.Text = "Pause";
                }
                else
                {
                    pauseButton.Text = "Resume";
                }
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Pauses or unpauses playback
        /// </summary>
        private void Pause()
        {
            FMOD.RESULT result;
            bool        paused;

            //get paused status
            result = _channel.getPaused(out paused);
            CheckError(result);

            //unpause or pause
            result = _channel.setPaused(!paused);
            CheckError(result);

            //set IsPaused property to notify listeners
            IsPlaying = paused;

            //fire PlaybackStatusChanged event
            OnPlaybackStatusChanged();
        }
Ejemplo n.º 12
0
        public void Play()
        {
#if !NO_FMOD
            if (Playing && mChannel != null)
            {
                bool paused = false;
                mChannel.getPaused(ref paused);
                if (paused)
                {
                    mChannel.setPaused(false);
                    return;
                }
                else
                {
                    throw new InvalidOperationException();
                }
            }
            else
            {
                if (data._streamIndex >= 0)
                {
                    if (mStreamBytes != null)
                    {
                        mAbortStream = false;
                        return;
                    }
                    // if this isn't true, we may have 2 async requests to play, which would be super bad
                    GSGE.Debug.assert(mStreamBytes == null);
                    GSGE.Debug.assert(mAbortStream == false);
                }
                if (mSound != null)
                {
                    Dispose();
                }

                FMOD.RESULT            result;
                FMOD.CREATESOUNDEXINFO exinfo = SoundData.exinfo;
                exinfo.cbsize = Marshal.SizeOf(exinfo);

                // allocate streaming?
                if (data._size > 0)
                {
                    mStreamRequested = true;
                    mStreamBytes     = new byte[data._size];

                    string file = "Content/Audio/";
                    if (data._persist)
                    {
                        file += "Deferred/";
                    }
                    else
                    {
                        file += "Streaming/";
                    }
                    file += data._streamIndex;
                    file += ".mp3";


                    //GSGE.Debug.logMessage("streaming audio " + file);
                    NaCl.AsyncFS.FileStream fs = new NaCl.AsyncFS.FileStream(file, System.IO.FileMode.Open);

                    fs.BeginRead(mStreamBytes,
                                 0,
                                 mStreamBytes.Length,
                                 delegate(IAsyncResult aresult)
                    {
                        int bytesRead;
                        try
                        {
                            bytesRead = fs.EndRead(aresult);
                        }
                        catch (System.IO.FileNotFoundException)
                        {
                            bytesRead = -1;
                        }
                        fs.Close();

                        if (bytesRead != data._size)
                        {
                            GSGE.Debug.logMessage("Error streaming in sound " + data._streamIndex);
                            mStreamStarted = true;
                            Dispose();
                            return;
                        }

                        if (data._persist)
                        {
                            byte[] audiodata = mStreamBytes;

                            mStreamBytes     = null;
                            mStreamRequested = false;
                            mStreamStarted   = false;

                            // reconfigure parent Sound to be persistent now.
                            data.setPersistent(audiodata);

                            if (mAbortStream)
                            {
                                Dispose();
                            }
                            else
                            {
                                Play();
                            }
                        }
                        else
                        {
                            mStreamStarted = true;
                            if (mAbortStream)
                            {
                                Dispose();
                            }
                            else
                            {
                                exinfo.length  = (uint)mStreamBytes.Length;
                                FMOD.MODE mode = FMOD.MODE.OPENMEMORY_POINT | FMOD.MODE.CREATECOMPRESSEDSAMPLE | FMOD.MODE.SOFTWARE;
                                if (data._looping)
                                {
                                    mode |= FMOD.MODE.LOOP_NORMAL;
                                }
                                result    = FMOD.Framework.system.createSound(mStreamBytes, mode, ref exinfo, ref mSound);
                                mOwnSound = true;
                                ERRCHECK(result);

                                AudioEngine audioengine = GSGE.AudioManager.GetAudioManager().GetAudioEngine();
                                audioengine.FmodSounds.Add(this);

                                result = FMOD.Framework.system.playSound(FMOD.CHANNELINDEX.FREE, mSound, false, ref mChannel);
                                if (mSound == null)
                                {
                                    Dispose();
                                }
                                else
                                {
                                    GSGE.Debug.assert(mSound != null);
                                    ERRCHECK(result);
                                    mChannel.getFrequency(ref mBaseFrequency);
                                }
                            }
                        }

                        // all streaming sounds need to assign these asap
                        Volume        = _volume;
                        Pitch         = _pitch;
                        LowPassCutoff = _lowPassCutoff;
                        Reverb        = _reverb;

                        mAbortStream = false;
                    }, null);
                }
                else
                {
                    if (data.mSound == null)
                    {
                        data.createSound();
                    }

                    //exinfo.length = (uint)data.data.Length;
                    //FMOD.MODE mode = FMOD.MODE.OPENMEMORY_POINT | FMOD.MODE.CREATECOMPRESSEDSAMPLE | FMOD.MODE.SOFTWARE;
                    //if (data._looping)
                    //    mode |= FMOD.MODE.LOOP_NORMAL;
                    //result = FMOD.Framework.system.createSound(data.data, mode, ref exinfo, ref mSound);

                    //ERRCHECK(result);

                    mSound = data.mSound;
                    if (mSound == null)
                    {
                        Dispose();
                        return;
                    }
                    GSGE.Debug.assert(mSound != null);

                    AudioEngine audioengine = GSGE.AudioManager.GetAudioManager().GetAudioEngine();
                    audioengine.FmodSounds.Add(this);

                    result = FMOD.Framework.system.playSound(FMOD.CHANNELINDEX.FREE, mSound, false, ref mChannel);
                    GSGE.Debug.assert(mSound != null);
                    ERRCHECK(result);
                    mChannel.getFrequency(ref mBaseFrequency);
                }
            }
#endif
        }