private void send(string action, ApplicationIcon toSend)
        {
            toSend.id = AudioSession.getCode(toSend.id);
            string data = action + JSONManager.serialize(toSend);

            send(data);
        }
        private void Form1_OnAudioSessionAdded(AudioSession session)
        {
            Console.WriteLine("Audio session added " + session.title + ":" + session.id);
            AudioSession.registerSessionID(session.id);
            ApplicationIcon icon = Main.Instance.audioManager.getSessionIcon(session.id);

            send("ADD", session);
            send("IMG", icon);
        }
示例#3
0
        public ApplicationIcon getSessionIcon(string sessionID)
        {
            int i = 0;

            foreach (AudioSession session in AudioSessions.Values)
            {
                if (session.pid != 0 && session.id == sessionID)
                {
                    i++;
                    ApplicationIcon icon      = new ApplicationIcon();
                    Bitmap          bmp       = getApplicationIcon(session.pid);
                    ImageConverter  converter = new ImageConverter();
                    icon.icon = Convert.ToBase64String((byte[])converter.ConvertTo(bmp, typeof(byte[])));
                    icon.id   = session.id;
                    return(icon);
                }
            }
            return(null);
        }
示例#4
0
        public ApplicationIcon[] getSessionIcons()
        {
            List <ApplicationIcon> icons = new List <ApplicationIcon>();

            for (int i = 0; i < device.AudioSessionManager2.Sessions.Count; i++)
            {
                AudioSessionControl2 sessionControl = device.AudioSessionManager2.Sessions[i];
                if (sessionControl.State != AudioSessionState.AudioSessionStateExpired)
                {
                    ApplicationIcon icon = getSessionIcon(sessionControl.GetID());
                    if (icon != null)
                    {
                        icons.Add(icon);
                    }
                }
            }


            return(icons.ToArray());
        }