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


C# IWaveSource.GetLength方法代码示例

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


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

示例1: UpdateMetadata

        void UpdateMetadata(IWaveSource source)
        {
            // duration of the last track imported from a CUE sheet is not initially known;
            // update it now that we have audio source decoded; this update is only valid for the last track!
            if (_duration == TimeSpan.Zero)
            {
                var duration = source.GetLength();
                _duration = duration - Offset;
                SetDuration(_duration);
            }

            kHz = source.WaveFormat.SampleRate / 1000;
            kbps = source.WaveFormat.BytesPerSecond * 8 / 1000;
        }
开发者ID:WELL-E,项目名称:Hurricane,代码行数:14,代码来源:LocalTrackFragment.cs

示例2: FromSoundSource

 public static SoundSourceInfo FromSoundSource(IWaveSource source)
 {
     return new SoundSourceInfo { kHz = source.WaveFormat.SampleRate / 1000, Duration = source.GetLength() };
 }
开发者ID:WELL-E,项目名称:Hurricane,代码行数:4,代码来源:SoundSourceInfo.cs

示例3: PlaybackStoppedEventTestInternal

        private void PlaybackStoppedEventTestInternal(ISoundOut soundOut, IWaveSource source)
        {
            for (int i = 0; i < BasicIterationCount; i++)
            {
                bool raised = false;
                soundOut.Stopped += (s, e) => raised = true;

                //1. wait for the event on end of stream
                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep((int)(source.GetLength().TotalMilliseconds + 50));
                while (soundOut.PlaybackState != PlaybackState.Stopped)
                    Thread.Sleep(10);

                soundOut.Initialize(source); //the playbackstate may be stopped but event was not fired. initialize will wait until it gets fired.

                source.Position = 0;
                Assert.IsTrue(raised);
                raised = false;

                //2. event on Stop()
                soundOut.Play();

                Thread.Sleep(50);
                soundOut.Stop();

                Assert.IsTrue(raised);
            }
        }
开发者ID:hoangduit,项目名称:cscore,代码行数:30,代码来源:SoundOutBehaviourTests.cs

示例4: CanHandleEOFTestInternal

        private void CanHandleEOFTestInternal(ISoundOut soundOut, IWaveSource source)
        {
            int sourceLength = (int)source.GetLength().TotalMilliseconds;
            Debug.WriteLine(soundOut.GetType().FullName);
            for (int i = 0; i < BasicIterationCount; i++)
            {
                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Pause();
                soundOut.Resume();

                Thread.Sleep(10);

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 1000);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");
                Assert.AreEqual(PlaybackState.Stopped, soundOut.PlaybackState);

                source.Position = 0;
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");
            }
        }
开发者ID:hoangduit,项目名称:cscore,代码行数:43,代码来源:SoundOutBehaviourTests.cs

示例5: CanHandleEOFTestInternal

        private void CanHandleEOFTestInternal(ISoundOut soundOut, IWaveSource source)
        {
            int sourceLength = (int)source.GetLength().TotalMilliseconds;
            for (int i = 0; i < basic_iteration_count; i++)
            {
                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                soundOut.Pause();
                soundOut.Resume();

                Thread.Sleep(10);

                soundOut.Stop();
                source.Position = 0;

                soundOut.Initialize(source);
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");

                source.Position = 0;
                soundOut.Play();

                Thread.Sleep(sourceLength + 500);
                Assert.AreEqual(source.Length, source.Position, "Source is not EOF");
            }
        }
开发者ID:CheViana,项目名称:AudioLab,代码行数:41,代码来源:SoundOutBehaviourTest.cs

示例6: ttbbPrev_Click

        private void ttbbPrev_Click(object sender, ThumbnailButtonClickedEventArgs e)
        {
            Changing = true;
            player.Stop();
            t.Stop();
            if (ActualFileIndex == 0)
                ActualFileIndex = Playlist.Count - 1;
            else
                ActualFileIndex--;

            GetAndFillWithSongInfo();

            source = CodecFactory.Instance.GetCodec(Playlist[ActualFileIndex]);
            if (playerInit)
            {
                ttbbPlayPause.Icon = Icon.FromHandle(ToolbarIcons.ic_play_arrow_white_18dp.GetHicon());
                ttbbPlayPause.Tooltip = "Wznów odtwarzanie";
                mbtnPlayPause.Image = PlayerControlIcons.ic_pause_grey600_48dp;
                player.Initialize(source);
                source.SetPosition(new TimeSpan(0, 0, 0));
                t.Start();
                player.Play();
                mtbTime.Maximum = Convert.ToInt32(source.GetLength().TotalSeconds);
                mtbTime.Value = 0;
            }
        }
开发者ID:Jakub-jk,项目名称:Songer-OLD-,代码行数:26,代码来源:Form1.cs

示例7: Form1

        public Form1()
        {
            //MetroMessageBox.Show(this, string.Format("{0} - 1, {1} - 2, {2} - 3", StylesList[1], StylesList[2], StylesList[3]));
            InitializeComponent();

            #region Player Initialization
            player = GetSoundOut();
            playerInit = true;
            player.Stopped += new EventHandler<PlaybackStoppedEventArgs>(player_Stopped);
            #endregion

            LoadFromSettings();

            #region Settings Initialization
            for (int i = 1; i < Enum.GetNames(typeof(MetroColorStyle)).Length; i++)
                mcbStyles.Items.Add(StylesList[i]);
            mcbThemes.Items.Add(ThemesList[1]);
            mcbThemes.Items.Add(ThemesList[2]);
            mcbThemes.SelectedItem = msm.Theme;
            mcbStyles.SelectedItem = msm.Style;
            #endregion

            #region Taskbar Buttons Add & Delegates
            ttbbPlayPause.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(ttbbPlayPause_Click);
            ttbbNext.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(ttbbNext_Click);
            ttbbPrev.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(ttbbPrev_Click);
            ttbbForward.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(ttbbForward_Click);
            ttbbRewind.Click += new EventHandler<ThumbnailButtonClickedEventArgs>(ttbbRewind_Click);

            TaskbarManager.Instance.ThumbnailToolBars.AddButtons(this.Handle, ttbbPrev, ttbbRewind, ttbbPlayPause, ttbbForward, ttbbNext);
            #endregion

            #region Song Initialization
            foreach (FileInfo fi in (new DirectoryInfo(Path.GetFullPath("TestMusic")).GetFiles()))
                Playlist.Add(fi.FullName);
            //TODO: MAKE IT WORKING!
            /*System.Drawing.Text.PrivateFontCollection pfc = new System.Drawing.Text.PrivateFontCollection();
            pfc.AddFontFile(Path.GetFullPath("comfortaa.ttf"));
            Font = new Font(pfc.Families[0], Font.Size, Font.Style);
            foreach (Control c in Controls)
                c.Font = new Font(pfc.Families[0],c.Font.Size, c.Font.Style);*/
            GetAndFillWithSongInfo();

            source = CodecFactory.Instance.GetCodec(Playlist[ActualFileIndex]);
            ActualFileIndex = 0;
            player.Initialize(source);
            player.Play();
            mtbTime.Maximum = Convert.ToInt32(source.GetLength().TotalSeconds);
            mtbTime.Value = 0;
            t.Tick += new EventHandler(Tick);
            t.Start();
            #endregion

            //AddTrackToList(Playlist[0], Playlist[1]);
        }
开发者ID:Jakub-jk,项目名称:Songer-OLD-,代码行数:55,代码来源:Form1.cs

示例8: player_Stopped

        private void player_Stopped(object sender, PlaybackStoppedEventArgs e)
        {
            if (!Changing)
            {
                //MessageBox.Show(e.Exception.ToString());
                t.Stop();
                if (ActualFileIndex == Playlist.Count - 1)
                    ActualFileIndex = 0;
                else
                    ActualFileIndex++;

                GetAndFillWithSongInfo();

                source = CodecFactory.Instance.GetCodec(Playlist[ActualFileIndex]);
                if (playerInit)
                {
                    ttbbPlayPause.Icon = Icon.FromHandle(ToolbarIcons.ic_play_arrow_white_18dp.GetHicon());
                    ttbbPlayPause.Tooltip = "Wznów odtwarzanie";
                    player.Initialize(source);
                    source.SetPosition(new TimeSpan(0, 0, 0));
                    t.Start();
                    player.Play();
                    mtbTime.Maximum = Convert.ToInt32(source.GetLength().TotalSeconds);
                    mtbTime.Value = 0;
                }
            }
        }
开发者ID:Jakub-jk,项目名称:Songer-OLD-,代码行数:27,代码来源:Form1.cs


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