示例#1
0
        protected virtual void SetVolume(bool isMuted)
        {
            try
            {
                _mixer.IsMuted = isMuted;


                GUIMessage msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_AUDIOVOLUME_CHANGED, 0, 0, 0, 0, 0, 0);
                msg.Label  = Instance.Step.ToString();
                msg.Label2 = Instance.StepMax.ToString();
                msg.Label3 = Instance.IsMuted.ToString();
                GUIGraphicsContext.SendMessage(msg);


                if (GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_TVFULLSCREEN && _showVolumeOSD ||
                    GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO && _showVolumeOSD)
                {
                    Action showVolume = new Action(Action.ActionType.ACTION_SHOW_VOLUME, 0, 0);
                    GUIWindowManager.OnAction(showVolume);
                }
            }
            catch (Exception e)
            {
                Log.Info("VolumeHandler.SetVolume: {0}", e.Message);
            }
        }
示例#2
0
        private void HandleGUIOnControlChange()
        {
            try
            {
                var msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_AUDIOVOLUME_CHANGED, 0, 0, 0, 0, 0, 0)
                {
                    Label  = Instance.Step.ToString(CultureInfo.InvariantCulture),
                    Label2 = Instance.StepMax.ToString(CultureInfo.InvariantCulture),
                    Label3 = Instance.IsMuted.ToString(CultureInfo.InvariantCulture)
                };
                GUIGraphicsContext.SendMessage(msg);

                var showVolume = new Action(Action.ActionType.ACTION_SHOW_VOLUME, 0, 0);
                GUIWindowManager.OnAction(showVolume);
            }
            catch (Exception ex)
            {
                Log.Error($"VolumeHandler: error occured in HandleGUIOnControlChange: {ex}");
            }
        }
        public override void OnAction(Action action)
        {
            if (action.wID == Action.ActionType.ACTION_KEY_PRESSED)
            {
                // translate the action as if our window was the WINDOW_FULLSCREEN_VIDEO
                if (ActionTranslator.GetAction((int)Window.WINDOW_FULLSCREEN_VIDEO, action.m_key, ref action))
                {
                    if (action.wID == Action.ActionType.ACTION_SHOW_OSD)                     // handle the OSD action differently - we need to show our OSD
                    {
                        base.OnAction(action);
                        if (GUIWindowManager.VisibleOsd == Window.WINDOW_OSD)
                        {
                            GUIWindowManager.VisibleOsd = (Window)GUIOnlineVideoOSD.WINDOW_ONLINEVIDEOS_OSD;
                        }
                        return;
                    }
                    else if (action.wID == Action.ActionType.ACTION_SHOW_GUI ||
                             action.wID == Action.ActionType.ACTION_NEXT_SUBTITLE)
                    {
                        return;                         // already handled by base class, but get's sent here again as keypress, so when we map it we must make sure not to handle it again
                    }
                    else if (action.wID == Action.ActionType.ACTION_VOLUME_UP ||
                             action.wID == Action.ActionType.ACTION_VOLUME_DOWN ||
                             action.wID == Action.ActionType.ACTION_VOLUME_MUTE)
                    {
                        // MediaPortal core sends this message to the Fullscreenwindow, we need to do it ourselves to make the Volume OSD show up
                        GUIWindowManager.SendThreadCallback((p1, p2, o) =>
                        {
                            Action showVolume = new Action(Action.ActionType.ACTION_SHOW_VOLUME, 0, 0);
                            GUIWindowManager.OnAction(showVolume);
                            return(0);
                        }, 0, 0, null);
                        return;
                    }
                }
            }

            base.OnAction(action);
        }
示例#4
0
        private void HandleGUIOnControlChange()
        {
            try
            {
                var msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_AUDIOVOLUME_CHANGED, 0, 0, 0, 0, 0, 0)
                {
                    Label  = Instance.Step.ToString(CultureInfo.InvariantCulture),
                    Label2 = Instance.StepMax.ToString(CultureInfo.InvariantCulture),
                    Label3 = Instance.IsMuted.ToString(CultureInfo.InvariantCulture)
                };
                GUIGraphicsContext.SendMessage(msg);

                if (GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_TVFULLSCREEN && _showVolumeOSD ||
                    GUIWindowManager.ActiveWindow == (int)GUIWindow.Window.WINDOW_FULLSCREEN_VIDEO && _showVolumeOSD)
                {
                    var showVolume = new Action(Action.ActionType.ACTION_SHOW_VOLUME, 0, 0);
                    GUIWindowManager.OnAction(showVolume);
                }
            }
            catch (Exception e)
            {
                Log.Info("VolumeHandler.HandleGUIOnControlChange: {0}", e.ToString());
            }
        }
示例#5
0
        private void Listener_XplMessageReceived(object sender, XplListener.XplEventArgs e)
        {
            if (e.XplMsg.Schema.msgClass.ToLower().Equals("hbeat") && e.XplMsg.Schema.msgType.ToLower().Equals("app"))
            {
                if (this.DoDebug)
                {
                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received HEARTBEAT");
                }
                this._IsConnected = true;
            }
            else if (e.XplMsg.Schema.msgClass.ToLower().Equals("config"))
            {
                if (this.DoDebug)
                {
                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received CONFIG message");
                }
            }
            else if ((e.XplMsg.Source.Vendor.ToLower().Equals(this.mVendorID.ToLower()) &&
                      e.XplMsg.Source.Device.ToLower().Equals(this.mDeviceID.ToLower())) &&
                     e.XplMsg.Source.Instance.ToLower().Equals(this.mInstanceID.ToLower()))
            {
                if (this.DoDebug)
                {
                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received ECHO");
                }
            }
            else
            {
                if (this.DoDebug)
                {
                    Log.Info("xPLConnector_Listener_XplMessageReceived: {0} - {1} - {2}",
                             new object[] { e.XplMsg.Source.Vendor, e.XplMsg.Source.Device, e.XplMsg.Content });
                }
                string str   = e.XplMsg.Schema.msgClass.ToLower() + "." + e.XplMsg.Schema.msgType.ToLower();
                string str11 = str;
                if (str11 != null)
                {
                    if (!(str11 == "media.basic"))
                    {
                        if (!(str11 == "media.request"))
                        {
                            if (str11 == "remote.basic")
                            {
                                foreach (string str9 in e.XplMsg.GetParam(1, "keys").Split(new char[] { ',' }))
                                {
                                    if (this.DoDebug)
                                    {
                                        Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic \"{0}\"",
                                                 new object[] { str9 });
                                    }
                                    if (Enum.IsDefined(typeof(GUIWindow.Window), str9.ToUpper()))
                                    {
                                        if (this.DoDebug)
                                        {
                                            Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic window name",
                                                     new object[0]);
                                        }
                                        this.XPL_Send_Remote_Confirm_Message(e);
                                        int num8 = (int)Enum.Parse(typeof(GUIWindow.Window), str9.ToUpper());
                                        if (!GUIWindowManager.ActiveWindow.Equals(num8))
                                        {
                                            GUIWindowManager.SendThreadCallbackAndWait(
                                                new GUIWindowManager.Callback(this.ThreadMessageCallback), 1, num8, null);
                                            return;
                                        }
                                        break;
                                    }
                                    if (Enum.IsDefined(typeof(Keys), str9))
                                    {
                                        if (this.DoDebug)
                                        {
                                            Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic key name",
                                                     new object[0]);
                                        }
                                        this.XPL_Send_Remote_Confirm_Message(e);
                                        Key    key     = new Key(0, (int)Enum.Parse(typeof(Keys), str9));
                                        Action action3 = new Action();
                                        if (ActionTranslator.GetAction(GUIWindowManager.ActiveWindow, key, ref action3))
                                        {
                                            GUIWindowManager.OnAction(action3);
                                            return;
                                        }
                                    }
                                    foreach (string str10 in Enum.GetNames(typeof(RemoteButton)))
                                    {
                                        if (str10.ToLower().Equals(str9.ToLower()) || str9.ToLower().Equals("remote_" + str10.ToLower()))
                                        {
                                            if (this.DoDebug)
                                            {
                                                Log.Info(
                                                    "xPL_Connector.Listener_XplMessageReceived(): Received remote.basic remote key name \"{0}\"",
                                                    new object[] { str9 });
                                            }
                                            this.XPL_Send_Remote_Confirm_Message(e);
                                            if (!this.rHandler.MapAction((int)Enum.Parse(typeof(RemoteButton), str10)) && this.DoDebug)
                                            {
                                                Log.Info(
                                                    "xPL_Connector.Listener_XplMessageReceived(): COULD NOT FIRE REMOTE ACTION (isLoaded = {0})",
                                                    new object[] { this.rHandler.IsLoaded });
                                            }
                                            break;
                                        }
                                    }
                                    int result = 0;
                                    int.TryParse(str9, out result);
                                    if (result != 0)
                                    {
                                        if (this.DoDebug)
                                        {
                                            Log.Info("xPL_Connector.Listener_XplMessageReceived(): Received remote.basic raw keycode",
                                                     new object[0]);
                                        }
                                        this.XPL_Send_Remote_Confirm_Message(e);
                                        Key    key2    = new Key(0, result);
                                        Action action4 = new Action();
                                        if (ActionTranslator.GetAction(GUIWindowManager.ActiveWindow, key2, ref action4))
                                        {
                                            GUIWindowManager.OnAction(action4);
                                            return;
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            switch (e.XplMsg.GetParam(1, "request"))
                            {
                            case "devinfo":
                                this.XPL_SendDevInfo("xpl-stat");
                                return;

                            case "devstate":
                                if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player"))
                                {
                                    this.XPL_SendPlayerDevstate("xpl-stat");
                                }
                                return;

                            case "mpinfo":
                                if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player"))
                                {
                                    this.XPL_SendPlayerMediaPlayerInfo("xpl-stat");
                                    this.XPL_SendPlayerMediaPlayerInputInfo("xpl-stat");
                                }
                                return;

                            case "mptrnspt":
                                if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player"))
                                {
                                    this.XPL_SendPlayerTransportState("xpl-stat");
                                }
                                return;

                            case "mpmedia":
                                if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player"))
                                {
                                    this.XPL_SendMediaInfo("xpl-stat");
                                }
                                return;

                            case "mpconfig":
                                if (e.XplMsg.GetParam(1, "mp").ToLower().Equals("player"))
                                {
                                    this.XPL_SendPlayerMediaPlayerConfig("xpl-stat");
                                }
                                return;

                            case "mpqueue":
                                return;
                            }
                        }
                    }
                    else
                    {
                        int num;
                        switch (e.XplMsg.GetParam(1, "command").ToLower())
                        {
                        case "record":
                        case "position":
                        case "chapter":
                        case "power":
                        case "reboot":
                        case "input":
                        case "options":
                            return;

                        case "play":
                        {
                            string path = e.XplMsg.GetParam(1, "url").ToLower();
                            if (!(path.Equals(string.Empty) & g_Player.Paused))
                            {
                                if (path.Equals(g_Player.currentFileName) & g_Player.Paused)
                                {
                                    g_Player.Pause();
                                    if (this.DoDebug)
                                    {
                                        Log.Info(
                                            "xPLConnector_Listener_XplMessageReceived: Received media.basic play file command (unpause)",
                                            new object[0]);
                                        return;
                                    }
                                    return;
                                }
                                if (File.Exists(path) && !g_Player.currentFileName.Equals(path))
                                {
                                    GUIMessage message = new GUIMessage();
                                    message.Message = GUIMessage.MessageType.GUI_MSG_PLAY_FILE;
                                    message.Label   = path;
                                    GUIWindowManager.SendThreadMessage(message);
                                    if (!this.DoDebug)
                                    {
                                        return;
                                    }
                                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic play file command",
                                             new object[0]);
                                }
                                return;
                            }
                            g_Player.Pause();
                            if (this.DoDebug)
                            {
                                Log.Info(
                                    "xPLConnector_Listener_XplMessageReceived: Received media.basic play file command (unpause)",
                                    new object[0]);
                            }
                            return;
                        }

                        case "stop":
                        {
                            GUIMessage message2 = new GUIMessage();
                            message2.Message = GUIMessage.MessageType.GUI_MSG_STOP_FILE;
                            GUIWindowManager.SendThreadMessage(message2);
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic stop command",
                                         new object[0]);
                            }
                            return;
                        }

                        case "pause":
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic pause command",
                                         new object[0]);
                            }
                            if (!g_Player.Paused)
                            {
                                g_Player.Pause();
                            }
                            return;

                        case "forward":
                        {
                            string str4 = e.XplMsg.GetParam(1, "speed").ToLower();
                            num = 0;
                            if (!str4.Equals(string.Empty))
                            {
                                num = int.Parse(str4.Replace("x", ""));
                                break;
                            }
                            num = g_Player.Speed * 2;
                            break;
                        }

                        case "rewind":
                        {
                            string str5 = e.XplMsg.GetParam(1, "speed").ToLower();
                            int    num2 = 0;
                            if (!str5.Equals(string.Empty))
                            {
                                num2 = int.Parse(str5.Replace("x", ""));
                            }
                            else
                            {
                                num2 = Math.Abs(g_Player.Speed) * 2;
                            }
                            if (num2 > 0x20)
                            {
                                num2 = 0x20;
                            }
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic rewind ({0}x) command",
                                         new object[] { num2 });
                            }
                            g_Player.Speed = -num2;
                            return;
                        }

                        case "next":
                            Action action;
                            if (!g_Player.IsDVD)
                            {
                                action = new Action(Action.ActionType.ACTION_NEXT_ITEM, 0f, 0f);
                            }
                            else
                            {
                                action = new Action(Action.ActionType.ACTION_NEXT_CHAPTER, 0f, 0f);
                            }
                            GUIGraphicsContext.OnAction(action);
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic next command",
                                         new object[0]);
                            }
                            return;

                        case "back":
                            Action action2;
                            if (!g_Player.IsDVD)
                            {
                                action2 = new Action(Action.ActionType.ACTION_PREV_ITEM, 0f, 0f);
                            }
                            else
                            {
                                action2 = new Action(Action.ActionType.ACTION_PREV_CHAPTER, 0f, 0f);
                            }
                            GUIGraphicsContext.OnAction(action2);
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic back command",
                                         new object[0]);
                            }
                            return;

                        case "mute":
                            if (!(e.XplMsg.GetParam(1, "state").ToLower() == "on"))
                            {
                                if (this.DoDebug)
                                {
                                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic mute off command",
                                             new object[0]);
                                }
                                VolumeHandler.Instance.IsMuted = false;
                                return;
                            }
                            if (this.DoDebug)
                            {
                                Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic mute on command",
                                         new object[0]);
                            }
                            VolumeHandler.Instance.IsMuted = true;
                            return;

                        case "volume":
                        {
                            string str13;
                            string s = e.XplMsg.GetParam(1, "level").ToLower();
                            if (((str13 = s.Substring(0, 1)) == null) || (!(str13 == "+") && !(str13 == "-")))
                            {
                                int num7 = int.Parse(s);
                                VolumeHandler.Instance.Volume = (VolumeHandler.Instance.Maximum / 100) * num7;
                                if (this.DoDebug)
                                {
                                    Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic volume command",
                                             new object[0]);
                                }
                                return;
                            }
                            int volume = VolumeHandler.Instance.Volume;
                            int num5   = int.Parse(s) * 0x28f;
                            int num6   = volume + num5;
                            if (num6 < 0)
                            {
                                num6 = 0;
                            }
                            if (num6 > 0xffdc)
                            {
                                num6 = 0xffdc;
                            }
                            VolumeHandler.Instance.Volume = num6;
                            if (this.DoDebug)
                            {
                                Log.Info(
                                    "xPLConnector_Listener_XplMessageReceived: Received media.basic volume {0} command = orig = {1}, new = {2}, delta = {3}",
                                    new object[] { s, volume, num6, num5 });
                            }
                            return;
                        }

                        default:
                            return;
                        }
                        if (num > 0x20)
                        {
                            num = 0x20;
                        }
                        if (this.DoDebug)
                        {
                            Log.Info("xPLConnector_Listener_XplMessageReceived: Received media.basic play forward ({0}x) command",
                                     new object[] { num });
                        }
                        g_Player.Speed = num;
                    }
                }
            }
        }