/// <summary> /// Pres the buffer next. /// </summary> private void PreBufferNext() { var errorCount = 0; while (preBuffered.Count < prebufferSongs.Value) { var next = playlistService.Next(); if (null == next) { break; } var container = new TrackContainer(player, next); try { container.Preload(); } catch (Exception e) { container.Dispose(); ++errorCount; LogException(e, MethodBase.GetCurrentMethod()); LogWarning("File Was: {0}", container.File.Filename); if (errorCount >= 50) { LogCritical("Too many errors while prebuffering, giving up..."); break; } continue; } preBuffered.Add(container); LogInformation("PlayerService has {0} files PreBuffered", preBuffered.Count); } }
/// <summary> /// Plays this instance. /// </summary> /// <param name="file"></param> public virtual void Play(StorableTaggedFile file) { file.Guard("file"); var oldCurrent = CurrentTrack; var newChannel = new TrackContainer(player, file); try { newChannel.Preload(); } catch (Exception e) { newChannel.Dispose(); LogException(e, MethodBase.GetCurrentMethod()); LogWarning("File Was: {0}", file.Filename); return; } SwapChannels(newChannel); if (null != oldCurrent) { PushContainer(oldCurrent); } var index = playlistService.Files.IndexOf(file); if (index < 0) { return; } playlistService.SetPlaylistIndex(file); ReBuffer(); }
public virtual void Play(ITrack track) { var oldCurrent = CurrentTrack; var newChannel = new TrackContainer(track); try { newChannel.Preload(); } catch (Exception e) { newChannel.Dispose(); LogException(e, MethodBase.GetCurrentMethod()); LogWarning("Track Was: {0}", track); return; } SwapChannels(newChannel); if (null != oldCurrent) { PushContainer(oldCurrent); } playlistService.SetPlaylistIndex(null); ReBuffer(); }
private TrackContainer GetContainer(StorableTaggedFile file) { var channel = new TrackContainer(player, file); try { channel.Preload(); } catch { return(null); } return(channel); }