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


C# Loop.GetNextSegmentForPlayback方法代码示例

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


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

示例1: StartLoop

        /// <summary>
        /// Starts a loop. The playback must be activated.
        /// </summary>
        /// <param name="loop">Loop to apply</param>
        public void StartLoop(Loop loop)
        {
            if (Playlist == null || Playlist.CurrentItem == null || Playlist.CurrentItem.Channel == null)
                return;

            if (loop.Segments.Count == 0)
                return;

            long positionBytes = loop.Segments[_currentSegmentIndex].PositionBytes;
            long nextPositionBytes = 0;
            var segment = loop.GetNextSegmentForPlayback(_currentSegmentIndex);
            if (segment != null)
                nextPositionBytes = segment.PositionBytes;

            if (Playlist.CurrentItem.AudioFile.FileType == AudioFileFormat.FLAC && Playlist.CurrentItem.AudioFile.SampleRate > 44100)
            {
                // Divide by 1.5 (I don't really know why, but this works for 48000Hz and 96000Hz. Maybe a bug in BASS with FLAC files?)
                positionBytes = (long)((float)positionBytes / 1.5f);
            }

#if !IOS && !ANDROID
            if (_device.DriverType == DriverType.WASAPI)
            {
                BassWasapi.BASS_WASAPI_Stop(true);
                BassWasapi.BASS_WASAPI_Start();
            }
#endif

            // Remove any sync callback
            RemoveSyncCallbacks();

            // Get file length
            long length = Playlist.CurrentItem.Channel.GetLength();
            _mixerChannel.Lock(true);

            // Set position for the decode channel (needs to be in floating point)
            Playlist.CurrentItem.Channel.SetPosition(positionBytes * 2);
            _fxChannel.SetPosition(0); // Clear buffer
            _mixerChannel.SetPosition(0);

            // Set sync
            _syncProcLoop = new PlayerSyncProc();
#if IOS
            _syncProcLoop.SyncProc = new SYNCPROC(LoopSyncProcIOS);
#else
            _syncProcLoop.SyncProc = new SYNCPROC(LoopSyncProc);
#endif

            if (_mixerChannel is MixerChannel)
            {
                var mixerChannel = _mixerChannel as MixerChannel;
                _syncProcLoop.Handle = mixerChannel.SetSync(_fxChannel.Handle, BASSSync.BASS_SYNC_POS | BASSSync.BASS_SYNC_MIXTIME, (nextPositionBytes - positionBytes) * 2, _syncProcLoop.SyncProc);
            }
            else
            {
                _syncProcLoop.Handle = _mixerChannel.SetSync(BASSSync.BASS_SYNC_POS | BASSSync.BASS_SYNC_MIXTIME, (nextPositionBytes - positionBytes) * 2, _syncProcLoop.SyncProc);
            }

            // Set new callback (length already in floating point)
            SetSyncCallback((length - (nextPositionBytes * 2))); // + buffered));

            // Set offset position (for calulating current position)
            _positionOffset = positionBytes;
            _mixerChannel.Lock(false);
            _currentLoop = loop;
        }
开发者ID:pascalfr,项目名称:MPfm,代码行数:70,代码来源:Player.cs


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