public void SetSubtitle(IPlayerContext playerContext, string subtitle) { if (playerContext != null) { ISubtitlePlayer sp = playerContext.CurrentPlayer as ISubtitlePlayer; if (sp != null) { sp.SetSubtitle(subtitle); } } }
private static void SendCommand(string command) { Key button = null; switch (command.ToLower()) { case "stop": button = Key.Stop; break; case "record": button = Key.Record; break; case "pause": button = Key.PlayPause; break; case "play": button = Key.Play; break; case "rewind": button = Key.Rew; break; case "forward": button = Key.Fwd; break; case "replay": button = Key.Previous; break; case "skip": button = Key.Next; break; case "back": button = Key.Escape; break; case "info": button = Key.Info; break; case "menu": button = Key.ContextMenu; break; case "up": button = Key.Up; break; case "down": button = Key.Down; break; case "left": button = Key.Left; break; case "right": button = Key.Right; break; case "ok": button = Key.Ok; break; case "volup": button = Key.VolumeUp; break; case "voldown": button = Key.VolumeDown; break; case "volmute": button = Key.Mute; break; case "chup": button = Key.ChannelUp; break; case "chdown": button = Key.ChannelDown; break; case "dvdmenu": button = Key.DVDMenu; break; case "0": case "1": case "2": case "3": case "4": case "5": case "6": case "7": case "8": case "9": button = new Key(command[0]); break; case "clear": button = Key.Clear; break; case "enter": button = Key.Enter; break; case "teletext": button = Key.TeleText; break; case "red": button = Key.Red; break; case "blue": button = Key.Blue; break; case "yellow": button = Key.Yellow; break; case "green": button = Key.Green; break; case "home": button = Key.Home; break; case "basichome": button = Key.Home; break; case "nowplaying": //button = Key.NowPlaying; break; case "tvguide": button = Key.Guide; break; case "tvrecs": button = Key.RecordedTV; break; case "dvd": button = Key.DVDMenu; break; case "playlists": //button = RemoteButton.MyPlaylists; break; case "first": //button = RemoteButton.First; break; case "last": //button = RemoteButton.Last; break; case "fullscreen": button = Key.Fullscreen; break; case "subtitles": if (Helper.IsNowPlaying()) { ISubtitlePlayer subtitlePlayer = ServiceRegistration.Get <IPlayerContextManager>().PrimaryPlayerContext.CurrentPlayer as ISubtitlePlayer; if (subtitlePlayer != null) { var availableSubtitlesList = subtitlePlayer.Subtitles.ToList(); int index = 0; if (subtitlePlayer.CurrentSubtitle != null) { index = availableSubtitlesList.FindIndex(x => x == subtitlePlayer.CurrentSubtitle) + 1; if (index == (availableSubtitlesList.Count - 1)) { index = 0; } } subtitlePlayer.SetSubtitle(availableSubtitlesList[index]); } } break; case "audiotrack": if (Helper.IsNowPlaying()) { ISharpDXVideoPlayer videoPlayer = ServiceRegistration.Get <IPlayerContextManager>().PrimaryPlayerContext.CurrentPlayer as ISharpDXVideoPlayer; if (videoPlayer != null) { var availableAudiotracksList = videoPlayer.AudioStreams.ToList(); int index = 0; if (videoPlayer.CurrentAudioStream != null) { index = availableAudiotracksList.FindIndex(x => x == videoPlayer.CurrentAudioStream) + 1; if (index == (availableAudiotracksList.Count - 1)) { index = 0; } } videoPlayer.SetAudioStream(availableAudiotracksList[index]); } } break; /*case "screenshot": * button = Key.Screenshot; * break;*/ case "aspectratio": if (Helper.IsNowPlaying()) { ISharpDXVideoPlayer videoPlayer = ServiceRegistration.Get <IPlayerContextManager>().PrimaryPlayerContext.CurrentPlayer as ISharpDXVideoPlayer; if (videoPlayer != null) { var availableGeometriesList = availableGeometries.Values.ToList(); int index = 0; if (videoPlayer.GeometryOverride != null) { index = availableGeometriesList.FindIndex(x => x.Name == videoPlayer.GeometryOverride.Name) + 1; if (index == (availableGeometriesList.Count - 1)) { index = 0; } } videoPlayer.GeometryOverride = availableGeometriesList[index]; } } break; /*case "ejectcd": * button = RemoteButton.EjectCD; * break;*/ default: break; } if (button != null) { ServiceRegistration.Get <IInputManager>().KeyPress(button); } }