当前位置: 首页>>代码示例>>C#>>正文


C# IWavePlayer.Pause方法代码示例

本文整理汇总了C#中IWavePlayer.Pause方法的典型用法代码示例。如果您正苦于以下问题:C# IWavePlayer.Pause方法的具体用法?C# IWavePlayer.Pause怎么用?C# IWavePlayer.Pause使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IWavePlayer的用法示例。


在下文中一共展示了IWavePlayer.Pause方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: playSong

        /// <summary>
        /// Method that plays whatever the current song is
        /// </summary>
        private void playSong()
        {
            skipThis = false;
            Stream stream = Subsonic.StreamSong(currentSong.id);

            // Try to move this filling of memory stream into the background...
            Stream ms = new MemoryStream();
            byte[] buffer = new byte[32768];
            int read;
            while ((read = stream.Read(buffer, 0, buffer.Length)) > 0)
            {
                playerThread.ReportProgress(50);

                ms.Write(buffer, 0, read);
            }

            ms.Position = 0;
            Mp3FileReader mp3Reader = new Mp3FileReader(ms);
            WaveStream blockAlignedStream =
                new BlockAlignReductionStream(
                    WaveFormatConversionStream.CreatePcmStream(mp3Reader));
            WaveOut waveOut;
            waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback());
            waveOut.Init(blockAlignedStream);
            waveOut.Play();
            playState = PlaybackState.Playing;
            bool songEnd = false;
            while (playState != PlaybackState.Stopped && !songEnd && !skipThis)
            {
                if (waveOut.PlaybackState == PlaybackState.Stopped)
                    songEnd = true;
                else
                {
                    switch (playState)
                    {
                        case PlaybackState.Paused:
                            waveOut.Pause();
                            break;
                        case PlaybackState.Playing:
                            if (waveOut.PlaybackState != PlaybackState.Playing)
                                waveOut.Play();
                            else
                            {
                                int progress = (int)(100.0 * mp3Reader.CurrentTime.TotalSeconds / mp3Reader.TotalTime.TotalSeconds);
                                playerThread.ReportProgress(progress);
                                Thread.Sleep(100);
                            }
                            break;
                        default:
                            break;
                    }
                }
            }
            //if (playState == PlaybackState.Stopped)
            waveOut.Stop();
            //waveOut.Dispose();
        }
开发者ID:rogerstewart,项目名称:subsonic-csharp,代码行数:60,代码来源:PlayerForm.cs


注:本文中的IWavePlayer.Pause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。