/// <summary> /// Initializes a new instance of the BASSSong class. /// </summary> /// <param name="uv">The Ultraviolet context.</param> /// <param name="file">The path to the file from which to stream the song.</param> public BASSSong(UltravioletContext uv, String file) : base(uv) { Contract.RequireNotEmpty(file, nameof(file)); this.file = file; var stream = CreateStream(BASSNative.BASS_STREAM_DECODE); tags = new SongTagCollection(); ReadTagsFromStream(stream); var duration = BASSUtil.GetDurationInSeconds(stream); if (!BASSNative.StreamFree(stream)) { throw new BASSException(); } this.duration = TimeSpan.FromSeconds(duration); }