/// <summary> /// Gets the collection of tags associated with the specified sound. /// </summary> private static SongTagCollection GetTags(FMOD_SOUND *sound, out String name, out String artist, out String album) { var numtags = 0; var result = default(FMOD_RESULT); result = FMOD_Sound_GetNumTags(sound, &numtags, null); if (result != FMOD_OK) { throw new FMODException(result); } var tags = new SongTagCollection(); for (int i = 0; i < numtags; i++) { var tag = GetTag(sound, i); if (tag != null) { tags.Add(tag); } } name = tags["name"]?.Value ?? tags["title"]?.Value; artist = tags["artist"]?.Value; album = tags["album"]?.Value; return(tags); }
/// <summary> /// Reads any supported tags which are contained by the specified stream. /// </summary> private static SongTagCollection GetTags(UInt32 stream, out String name, out String artist, out String album) { var result = new SongTagCollection(); var tags = new Dictionary <String, String>(); if (ReadID3TagsFromStream(stream, out tags) || ReadOggTagsFromStream(stream, out tags)) { foreach (var tag in tags) { result.Add(tag.Key, tag.Value); } } name = result["name"]?.Value ?? result["title"]?.Value; artist = result["artist"]?.Value; album = result["album"]?.Value; return(result); }
/// <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); }
/// <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); }