public override IBassStream CreateBasicStream(PlaylistItem playlistItem, IEnumerable <IBassStreamAdvice> advice, BassFlags flags) { var fileName = this.GetFileName(playlistItem, advice); var channelHandle = BassDts.CreateStream(fileName, 0, 0, flags); return(this.CreateBasicStream(channelHandle, advice, flags)); }
public void Test002() { if (!Bass.Init(Bass.DefaultDevice)) { Assert.Fail(string.Format("Failed to initialize BASS: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } try { if (!BassDts.Load()) { Assert.Fail("Failed to load DTS."); } var sourceChannel = BassDts.CreateStream(Path.Combine(CurrentDirectory, this.FileName), 0, 0, this.BassFlags); if (sourceChannel == 0) { Assert.Fail(string.Format("Failed to create source stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } var channelInfo = default(ChannelInfo); if (!Bass.ChannelGetInfo(sourceChannel, out channelInfo)) { Assert.Fail(string.Format("Failed to get stream info: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } Assert.AreEqual(BassDts.ChannelType, channelInfo.ChannelType); if (!Bass.ChannelPlay(sourceChannel)) { Assert.Fail(string.Format("Failed to play the playback stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } var channelLength = Bass.ChannelGetLength(sourceChannel); var channelLengthSeconds = Bass.ChannelBytes2Seconds(sourceChannel, channelLength); Bass.ChannelSetPosition(sourceChannel, Bass.ChannelSeconds2Bytes(sourceChannel, channelLengthSeconds - 10), PositionFlags.Bytes); Thread.Sleep(2000); var channelPosition = Bass.ChannelGetPosition(sourceChannel); var channelPositionSeconds = Bass.ChannelBytes2Seconds(sourceChannel, channelPosition); Assert.IsTrue(channelPositionSeconds >= channelLengthSeconds - 10); if (!Bass.StreamFree(sourceChannel)) { Assert.Fail(string.Format("Failed to free the source stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } } finally { BassDts.Unload(); if (!Bass.Free()) { Assert.Fail(string.Format("Failed to free BASS: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } } }
public override Task <int> CreateStream(PlaylistItem playlistItem, BassFlags flags) { if (this.Output != null && this.Output.PlayFromMemory) { Logger.Write(this, LogLevel.Warn, "This provider cannot play from memory."); } #if NET40 return(TaskEx.FromResult(BassDts.CreateStream(playlistItem.FileName, 0, 0, flags))); #else return(Task.FromResult(BassDts.CreateStream(playlistItem.FileName, 0, 0, flags))); #endif }
public override IBassStream CreateInteractiveStream(PlaylistItem playlistItem, IEnumerable <IBassStreamAdvice> advice, BassFlags flags) { var fileName = this.GetFileName(playlistItem, advice); var channelHandle = default(int); if (this.Output != null && this.Output.PlayFromMemory) { Logger.Write(this, LogLevel.Warn, "This provider cannot play from memory."); } channelHandle = BassDts.CreateStream(fileName, 0, 0, flags); return(this.CreateInteractiveStream(channelHandle, advice, flags)); }
public void Test002() { if (!Bass.Init(Bass.DefaultDevice)) { Assert.Fail(string.Format("Failed to initialize BASS: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } //Plugin is not yet working. //if (Bass.PluginLoad(Path.Combine(CurrentDirectory, "bass_dts.dll")) == 0) //{ // Assert.Fail("Failed to load DTS."); //} var sourceChannel = BassDts.CreateStream(Path.Combine(CurrentDirectory, this.FileName), 0, 0, this.BassFlags); if (sourceChannel == 0) { Assert.Fail(string.Format("Failed to create source stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } if (!Bass.ChannelPlay(sourceChannel)) { Assert.Fail(string.Format("Failed to play the playback stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } var channelLength = Bass.ChannelGetLength(sourceChannel); var channelLengthSeconds = Bass.ChannelBytes2Seconds(sourceChannel, channelLength); Bass.ChannelSetPosition(sourceChannel, Bass.ChannelSeconds2Bytes(sourceChannel, channelLengthSeconds - 10), PositionFlags.Bytes); Thread.Sleep(2000); var channelPosition = Bass.ChannelGetPosition(sourceChannel); var channelPositionSeconds = Bass.ChannelBytes2Seconds(sourceChannel, channelPosition); Assert.IsTrue(channelPositionSeconds >= channelLengthSeconds - 10); if (!Bass.StreamFree(sourceChannel)) { Assert.Fail(string.Format("Failed to free the source stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } if (!Bass.Free()) { Assert.Fail(string.Format("Failed to free BASS: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } }
public void Test001(bool plugin) { if (!Bass.Init(Bass.DefaultDevice)) { Assert.Fail(string.Format("Failed to initialize BASS: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } try { if (!BassDts.Load()) { Assert.Fail("Failed to load DTS."); } var sourceChannel = default(int); if (plugin) { sourceChannel = Bass.CreateStream(Path.Combine(CurrentDirectory, this.FileName), 0, 0, this.BassFlags); } else { sourceChannel = BassDts.CreateStream(Path.Combine(CurrentDirectory, this.FileName), 0, 0, this.BassFlags); } if (sourceChannel == 0) { Assert.Fail(string.Format("Failed to create source stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } var channelInfo = default(ChannelInfo); if (!Bass.ChannelGetInfo(sourceChannel, out channelInfo)) { Assert.Fail(string.Format("Failed to get stream info: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } Assert.AreEqual(BassDts.ChannelType, channelInfo.ChannelType); if (!Bass.ChannelPlay(sourceChannel)) { Assert.Fail(string.Format("Failed to play the playback stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } var channelLength = Bass.ChannelGetLength(sourceChannel); var channelLengthSeconds = Bass.ChannelBytes2Seconds(sourceChannel, channelLength); do { if (Bass.ChannelIsActive(sourceChannel) == PlaybackState.Stopped) { break; } var channelPosition = Bass.ChannelGetPosition(sourceChannel); var channelPositionSeconds = Bass.ChannelBytes2Seconds(sourceChannel, channelPosition); Debug.WriteLine( "{0}/{1}", TimeSpan.FromSeconds(channelPositionSeconds).ToString("g"), TimeSpan.FromSeconds(channelLengthSeconds).ToString("g") ); Thread.Sleep(1000); } while (true); if (!Bass.StreamFree(sourceChannel)) { Assert.Fail(string.Format("Failed to free the source stream: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } } finally { BassDts.Unload(); if (!Bass.Free()) { Assert.Fail(string.Format("Failed to free BASS: {0}", Enum.GetName(typeof(Errors), Bass.LastError))); } } }