private void updateCurrentlyPlaying() { if (this.player == null) { return; } Logging.Log(LoggingArea, "Updating currently playing file"); // TODO: Show SFL this.display.SetIcon(iMonLcdIcons.Shuffle, this.player.Random); // TODO: Show REP this.display.SetIcon(iMonLcdIcons.Repeat, this.player.Repeat != XbmcRepeatTypes.Off); iMonLcdIcons icon; Logging.Log(LoggingArea, "Current player: " + this.player.ToString()); if (this.player is XbmcAudioPlayer) { if (!Settings.Default.XbmcIdleStaticTextEnable) { this.showSystemTime = !Settings.Default.XbmcMusicSingleTextEnable; } icon = iMonLcdIcons.Music; // TODO: Handle the situation when this.currentlyPlaying == null (i.e. the Playlist.Audio.GetCurrentItem() failed!!!) // E.g. move the fallback functions into the XbmcAudioPlaylist.GetCurrentItem() function this.currentlyPlaying = this.xbmc.Playlist.Audio.GetCurrentItem(); if (this.currentlyPlaying == null) { Logging.Error(LoggingArea, "Currently playing item not identified (XbmcAudioPlayer)"); } //Logging.Log(LoggingArea, "Current audio item: " + this.currentlyPlaying.); this.displaySong(); this.displayAudioCodecs(); } else if (this.player is XbmcPicturePlayer) { icon = iMonLcdIcons.Photo; if (!Settings.Default.XbmcIdleStaticTextEnable) { this.displaySlideshow(); } } else { icon = iMonLcdIcons.Movie; // TODO: Handle the situation when this.currentlyPlaying == null (i.e. the Playlist.Video.GetCurrentItem() failed!!!) // E.g. move the fallback functions into the XbmcVideoPlaylist.GetCurrentItem() function this.currentlyPlaying = this.xbmc.Playlist.Video.GetCurrentItem(); if (this.currentlyPlaying == null) { Logging.Error(LoggingArea, "Currently playing item not identified (XbmcVideoPlayer)"); } if (this.currentlyPlaying is XbmcTvEpisode) { if (!Settings.Default.XbmcIdleStaticTextEnable) { this.showSystemTime = !Settings.Default.XbmcTvSingleTextEnable; } if (Settings.Default.XbmcTvShowTvMediaTypeIcon) { icon = iMonLcdIcons.Tv; } if (Settings.Default.XbmcTvShowTvHdtvIcon) { string res = this.xbmc.System.GetInfoLabel("VideoPlayer.VideoResolution"); Logging.Log(LoggingArea, "Retrieved video resolution: " + res); int resolution; if (!string.IsNullOrEmpty(res) && Int32.TryParse(res, out resolution) && resolution >= 720) { this.display.SetIcon(iMonLcdIcons.AspectRatioHDTV, true); } else { this.display.SetIcon(iMonLcdIcons.AspectRatioTv, true); } } this.displayTvEpisode(); } else if (this.currentlyPlaying is XbmcMusicVideo) { if (!Settings.Default.XbmcIdleStaticTextEnable) { this.showSystemTime = !Settings.Default.XbmcMusicVideoSingleTextEnable; } this.displayMusicVideo(); } else { if (!Settings.Default.XbmcIdleStaticTextEnable) { this.showSystemTime = !Settings.Default.XbmcMovieSingleTextEnable; } this.displayMovie(); } this.displayVideoCodecs(); } if (Settings.Default.XbmcIconsPlaybackMediaType) { this.display.SetIcon(icon, true); } }
private void playbackStopped() { this.playerState = PlayerState.Stopped; this.player = null; this.currentlyPlaying = null; this.progressTimer.Stop(); this.position = new TimeSpan(); this.length = new TimeSpan(); this.Update(); }
private void updateCurrentlyPlaying() { if (this.player == null) { return; } Logging.Log("XBMC Handler", "Updating currently playing file"); // TODO: Show SFL this.display.SetIcon(iMonLcdIcons.Shuffle, this.player.Random); // TODO: Show REP this.display.SetIcon(iMonLcdIcons.Repeat, this.player.Repeat != XbmcRepeatTypes.Off); iMonLcdIcons icon; if (this.player is XbmcAudioPlayer) { icon = iMonLcdIcons.Music; this.currentlyPlaying = this.xbmc.Playlist.Audio.GetCurrentItem(); if (this.currentlyPlaying != null) { this.display.SetText(((XbmcSong)this.currentlyPlaying).Artist + " - " + this.currentlyPlaying.Title, ((XbmcSong)this.currentlyPlaying).Artist, this.currentlyPlaying.Title); string codec = ((XbmcAudioPlayer)this.player).Codec; if (!string.IsNullOrEmpty(codec)) { Dictionary<string, List<string>> mapping = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(Settings.Default.XbmcIconsPlaybackAudioCodecsMappings); foreach (KeyValuePair<string, List<string>> map in mapping) { if (this.listContains(map.Value, codec)) { this.displayAudioCodec(map.Key, true); break; } } } } else { Logging.Log("No information about this song available from the audio library => fall back to player info labels"); // Using InfoLabels as backup IDictionary<string, string> info = this.xbmc.System.GetInfoLabels("MusicPlayer.Title", "MusicPlayer.Artist"); if (info.Count > 0) { string lcd = string.Empty; string vfdUpper = string.Empty; string vfdLower = string.Empty; if (info.ContainsKey("MusicPlayer.Artist")) { lcd = info["MusicPlayer.Artist"]; vfdUpper = info["MusicPlayer.Artist"]; } if (info.ContainsKey("MusicPlayer.Title")) { if (!string.IsNullOrEmpty(lcd)) { lcd += " - "; } lcd += info["MusicPlayer.Title"]; vfdLower = info["MusicPlayer.Title"]; } this.display.SetText(lcd, vfdUpper, vfdLower); } else { Logging.Log("No information about this song from the player info labels either => fall back to the filename"); string path = this.xbmc.System.GetInfoLabel("Player.Filenameandpath"); if (!string.IsNullOrEmpty(path)) { this.display.SetText(Path.GetFileNameWithoutExtension(path)); } } } XbmcAudioPlayer audio = (XbmcAudioPlayer)this.player; } else if (this.player is XbmcPicturePlayer) { icon = iMonLcdIcons.Photo; this.display.SetText("SLIDESHOW", "Picture", "Slideshow"); } else { icon = iMonLcdIcons.Movie; this.currentlyPlaying = this.xbmc.Playlist.Video.GetCurrentItem(); if (this.currentlyPlaying != null) { if (this.currentlyPlaying is XbmcTvEpisode) { icon = iMonLcdIcons.Tv; XbmcTvEpisode ep = (XbmcTvEpisode)this.currentlyPlaying; this.display.SetText(ep.ShowTitle + ": S" + ep.Season.ToString("00") + "E" + ep.Episodes.ToString("00") + " " + ep.Title); } else { this.display.SetText(this.currentlyPlaying.Title); } string codec = ((XbmcVideoPlayer)this.player).VideoCodec; if (!string.IsNullOrEmpty(codec)) { Dictionary<string, List<string>> mapping = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(Settings.Default.XbmcIconsPlaybackVideoCodecsMappings); foreach (KeyValuePair<string, List<string>> map in mapping) { if (this.listContains(map.Value, codec)) { this.displayVideoCodec(map.Key); break; } } } codec = ((XbmcVideoPlayer)this.player).AudioCodec; if (!string.IsNullOrEmpty(codec)) { Dictionary<string, List<string>> mapping = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(Settings.Default.XbmcIconsPlaybackAudioCodecsMappings); foreach (KeyValuePair<string, List<string>> map in mapping) { if (this.listContains(map.Value, codec)) { this.displayAudioCodec(map.Key, false); break; } } } } else { // Using InfoLabels as backup IDictionary<string, string> info = this.xbmc.System.GetInfoLabels("VideoPlayer.Title", "VideoPlayer.TVShowTitle"); if (info.Count > 0) { string lcd = string.Empty; string vfdUpper = string.Empty; string vfdLower = string.Empty; if (info.ContainsKey("VideoPlayer.TVShowTitle")) { lcd = info["VideoPlayer.TVShowTitle"]; vfdUpper = info["VideoPlayer.TVShowTitle"]; } if (info.ContainsKey("VideoPlayer.Title")) { if (!string.IsNullOrEmpty(lcd)) { lcd += ": "; } string title = Path.GetFileNameWithoutExtension(info["VideoPlayer.Title"]); lcd += title; vfdLower = title; } this.display.SetText(lcd, vfdUpper, vfdLower); } else { string path = this.xbmc.System.GetInfoLabel("Player.Filenameandpath"); if (!string.IsNullOrEmpty(path)) { this.display.SetText(Path.GetFileNameWithoutExtension(path)); } } } XbmcVideoPlayer video = (XbmcVideoPlayer)this.player; } if (Settings.Default.XbmcIconsPlaybackMediaType) { this.display.SetIcon(icon, true); } }