public PlayableItem Create(Video video) { PlayableItem playable = null; if (PlayableExternal.CanPlay(video.Path)) { playable = new PlayableExternal(video.Path); } else if (PlayableVideoFile.CanPlay(video)) { playable = new PlayableVideoFile(video); } else if (PlayableIso.CanPlay(video)) { playable = new PlayableIso(video); } else if (PlayableMultiFileVideo.CanPlay(video)) { playable = new PlayableMultiFileVideo(video); } else if (PlayableDvd.CanPlay(video)) { playable = new PlayableDvd(video); } foreach (var controller in Kernel.Instance.PlaybackControllers) { if (controller.CanPlay(playable.Filename)) { playable.PlaybackController = controller; } } return(playable); }
public override void Prepare(bool resume) { musicFiles = music.MusicFiles.ToList(); if (musicFiles.Count == 1) { playListFile = musicFiles[0]; if (PlayableExternal.CanPlay(playListFile)) { this.playableExternal = new PlayableExternal(playListFile); } } else { musicFiles.Sort(); int pos = 0; if (resume) { pos = PlayState.PlaylistPosition; } if (PlayableExternal.CanPlay(musicFiles[0])) { playListFile = Path.Combine(ApplicationPaths.AutoPlaylistPath, music.Name + ".pls"); StringBuilder contents = new StringBuilder("[playlist]\n"); int x = 1; foreach (string file in musicFiles) { if (pos > 0) { pos--; } else { contents.Append("File" + x + "=" + file + "\n"); contents.Append("Title" + x + "=Part " + x + "\n\n"); } x++; } contents.Append("Version=2\n"); System.IO.File.WriteAllText(playListFile, contents.ToString()); this.playableExternal = new PlayableExternal(playListFile); } else { playListFile = CreateWPLPlaylist(music.Name, musicFiles.Skip(pos)); } } }
private List <PlayableItem> GetConfiguredExternalPlayerTypes() { List <PlayableItem> playables = new List <PlayableItem>(); IEnumerable <KeyValuePair <PlayableExternal, PlayableExternalConfigurator> > allPlayableExternals = RegisteredExternalPlayerTypes.Select(p => Activator.CreateInstance(p) as PlayableExternal) .Select(p => new KeyValuePair <PlayableExternal, PlayableExternalConfigurator>(p, Activator.CreateInstance(p.ConfiguratorType) as PlayableExternalConfigurator)); // Important - need to add them in the order they appear in configuration foreach (ConfigData.ExternalPlayer externalPlayerConfiguration in Config.Instance.ExternalPlayers) { if (allPlayableExternals.Any(p => p.Value.ExternalPlayerName == externalPlayerConfiguration.ExternalPlayerName)) { PlayableExternal playable = allPlayableExternals.FirstOrDefault(p => p.Value.ExternalPlayerName == externalPlayerConfiguration.ExternalPlayerName).Key; playable.ExternalPlayerConfiguration = externalPlayerConfiguration; playables.Add(playable); } } return(playables); }