Esempio n. 1
0
        public async Task <Stream> DownloadSoundAsync(string soundId)
        {
            if (IsLoggedIn)
            {
                return(await this.client.GetStreamAsync(new Uri ($"{ApiRoot}sounds/{soundId}/download/")));
            }

            FreeSoundInstance sound = await GetAsync(soundId, CancellationToken.None);

            if (sound.Previews.TryGetValue(PreviewHqOggField, out string url))
            {
                return(await this.client.GetStreamAsync(url));
            }
            else if (sound.Previews.TryGetValue(PreviewHqMp3Field, out url))
            {
                return(await this.client.GetStreamAsync(url));
            }

            return(null);
        }
Esempio n. 2
0
 private AudioContentEntry ToEntry(API.FreeSoundInstance instance)
 {
     return(new AudioContentEntry {
         Id = instance.Id,
         SourceUrl = $"https://freesound.org/sounds/{instance.Id}/",
         Name = instance.Name,
         Description = instance.Description,
         Author = new ContentAuthor {
             Name = instance.Username,
             Url = $"https://freesound.org/people/{instance.Username}/"
         },
         Duration = TimeSpan.FromSeconds(instance.Duration),
         License = instance.License,
         Size = instance.Filesize,
         Previews = instance.Previews?.Select(kvp => new ContentEntryPreview {
             Url = kvp.Value
         }).ToList(),
         Channels = ToChannels(instance.Channels),
         Frequency = instance.SampleRate
     });
 }