public Library(IRemovableDriveWatcher driveWatcher, ILibraryReader libraryReader, ILibraryWriter libraryWriter) { this.songLock = new object(); this.songs = new HashSet<Song>(); this.playlists = new List<Playlist>(); this.AccessMode = AccessMode.Administrator; // We want implicit to be the administrator, till we change to user mode manually this.cacheResetHandle = new AutoResetEvent(false); this.driveWatcher = driveWatcher; this.libraryReader = libraryReader; this.libraryWriter = libraryWriter; this.disposeLock = new object(); }
public Library(ILibraryReader libraryReader, ILibraryWriter libraryWriter, CoreSettings settings, IFileSystem fileSystem, Func <string, ILocalSongFinder> localSongFinderFunc = null) { if (libraryReader == null) { throw new ArgumentNullException(nameof(libraryReader)); } if (libraryWriter == null) { throw new ArgumentNullException(nameof(libraryWriter)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } if (fileSystem == null) { throw new ArgumentNullException(nameof(fileSystem)); } this.libraryReader = libraryReader; this.libraryWriter = libraryWriter; this.settings = settings; this.fileSystem = fileSystem; this.localSongFinderFunc = localSongFinderFunc ?? (x => new LocalSongFinder(x)); this.globalSubscriptions = new CompositeDisposable(); this.accessControl = new AccessControl(settings); this.songLock = new ReaderWriterLockSlim(); this.songs = new HashSet <LocalSong>(); this.playlists = new ReactiveList <Playlist>(); this.songsUpdated = new Subject <Unit>(); this.audioPlayer = new AudioPlayer(); this.manualUpdateTrigger = new Subject <Unit>(); this.LoadedSong = this.audioPlayer.LoadedSong; this.TotalTime = this.audioPlayer.TotalTime; this.PlaybackState = this.audioPlayer.PlaybackState; this.WhenAnyValue(x => x.CurrentPlaylist.CanPlayNextSong).SampleAndCombineLatest(this.audioPlayer.PlaybackState .Where(p => p == AudioPlayerState.Finished), (canPlayNextSong, _) => canPlayNextSong) .SelectMany(x => this.HandleSongFinishAsync(x).ToObservable()) .Subscribe(); this.CurrentPlaybackTime = this.audioPlayer.CurrentTimeChanged; this.volume = this.settings.WhenAnyValue(x => x.Volume) .ToProperty(this, x => x.Volume); }
public Library(IRemovableDriveWatcher driveWatcher, ILibraryReader libraryReader, ILibraryWriter libraryWriter, ILibrarySettings settings) { this.songLock = new object(); this.songs = new HashSet <Song>(); this.playlists = new List <Playlist>(); this.AccessMode = AccessMode.Administrator; // We want implicit to be the administrator, till we change to user mode manually this.cacheResetHandle = new AutoResetEvent(false); this.driveWatcher = driveWatcher; this.libraryReader = libraryReader; this.libraryWriter = libraryWriter; this.disposeLock = new object(); this.settings = settings; }
public Library(ILibraryReader libraryReader, ILibraryWriter libraryWriter, CoreSettings settings, IFileSystem fileSystem, Func<string, ILocalSongFinder> localSongFinderFunc = null) { if (libraryReader == null) throw new ArgumentNullException("libraryReader"); if (libraryWriter == null) throw new ArgumentNullException("libraryWriter"); if (settings == null) throw new ArgumentNullException("settings"); if (fileSystem == null) throw new ArgumentNullException("fileSystem"); this.libraryReader = libraryReader; this.libraryWriter = libraryWriter; this.settings = settings; this.fileSystem = fileSystem; this.localSongFinderFunc = localSongFinderFunc ?? (x => new LocalSongFinder(x)); this.globalSubscriptions = new CompositeDisposable(); this.accessControl = new AccessControl(settings); this.songLock = new ReaderWriterLockSlim(); this.songs = new HashSet<LocalSong>(); this.playlists = new ReactiveList<Playlist>(); this.songsUpdated = new Subject<Unit>(); this.audioPlayer = new AudioPlayer(); this.manualUpdateTrigger = new Subject<Unit>(); this.LoadedSong = this.audioPlayer.LoadedSong; this.TotalTime = this.audioPlayer.TotalTime; this.PlaybackState = this.audioPlayer.PlaybackState; this.WhenAnyValue(x => x.CurrentPlaylist.CanPlayNextSong).SampleAndCombineLatest(this.audioPlayer.PlaybackState .Where(p => p == AudioPlayerState.Finished), (canPlayNextSong, _) => canPlayNextSong) .SelectMany(x => this.HandleSongFinishAsync(x).ToObservable()) .Subscribe(); this.CurrentPlaybackTime = this.audioPlayer.CurrentTimeChanged; this.volume = this.settings.WhenAnyValue(x => x.Volume) .ToProperty(this, x => x.Volume); }
public LibraryBuilder WithWriter(ILibraryWriter writer) { this.writer = writer; return this; }
public static Library CreateLibrary(CoreSettings settings = null, ILibraryReader reader = null, ILibraryWriter writer = null, IFileSystem fileSystem = null, ILocalSongFinder localSongFinder = null) { return(new LibraryBuilder().WithReader(reader) .WithWriter(writer) .WithSettings(settings) .WithFileSystem(fileSystem) .WithSongFinder(localSongFinder) .Build()); }
public LibraryBuilder WithWriter(ILibraryWriter writer) { this.writer = writer; return(this); }