コード例 #1
0
        private void tmrKodiRefreshRate_Tick(object sender, EventArgs e)
        {
            KodiActivePlayers activePlayers = kodi.getActivePlayers();
            string            line1         = " ";
            string            line2         = " ";

            if (activePlayers.error != null && activePlayers.error.Length > 0)
            {
                line1 = activePlayers.error;
                tmrKodiRefreshRate.Enabled = false;
                btnConnect.Enabled         = true;
            }
            else
            {
                if (activePlayers.result.Length > 0)
                {
                    int playerid = getPlayerId(activePlayers);
                    KodiGetProperties propertiesResponse = kodi.getProperties(playerid);
                    for (int i = 0; i < activePlayers.result.Length; i++)
                    {
                        if (activePlayers.result[i].type == "video" && activePlayers.result[i].playerid == playerid)
                        {
                            KodiResponse itemResponse = kodi.getVideoItem(playerid);
                            line2 = propertiesResponse.result.time.ToString() + "  " + propertiesResponse.result.totaltime.ToString();
                            if (itemResponse.result.item.type == "movie")
                            {
                                line1 = itemResponse.result.item.movieToString();
                            }
                            else if (itemResponse.result.item.type == "episode")
                            {
                                line1 = itemResponse.result.item.episodeToString();
                            }
                            else if (itemResponse.result.item.type == "musicvideo")
                            {
                                line1 = itemResponse.result.item.musicvideoToString();
                            }
                            else if (itemResponse.result.item.type == "unknown")
                            {
                                line1 = itemResponse.result.item.unknownTypeToString();
                            }
                        }
                        else if (activePlayers.result[i].type == "audio" && activePlayers.result[i].playerid == playerid)
                        {
                            KodiResponse itemResponse = kodi.getAudioItem(playerid);
                            line2 = propertiesResponse.result.time.ToString() + "  " + propertiesResponse.result.totaltime.ToString();
                            if (itemResponse.result.item.type == "song")
                            {
                                line1 = itemResponse.result.item.songToString();
                            }
                        }
                        else if (activePlayers.result[i].type == "picture" && activePlayers.result[i].playerid == playerid)
                        {
                            KodiResponse itemResponse = kodi.getPictureItem(playerid);
                            if (itemResponse.result.item.type == "picture")
                            {
                                line1 = itemResponse.result.item.pictureToString();
                            }
                        }
                    }
                }
            }
            imon.setText(line1, line2);
        }
コード例 #2
0
        private void tmrRefreshRate_Tick(object sender, EventArgs e)
        {
            KodiActivePlayers activePlayers = kodi.getActivePlayers();


            if (activePlayers.error != null && activePlayers.error.Length > 0)
            {
                txtActivePlayers.Text  = activePlayers.error;
                tmrRefreshRate.Enabled = false;
                btnConnect.Enabled     = true;
            }
            else
            {
                if (activePlayers.result.Length > 0)
                {
                    int playerid = getPlayerId(activePlayers);
                    KodiGetProperties propertiesResponse = kodi.getProperties(playerid);
                    txtActivePlayers.Text = activePlayers.result[0].type;
                    for (int i = 0; i < activePlayers.result.Length; i++)
                    {
                        if (activePlayers.result[i].type == "video" && activePlayers.result[i].playerid == playerid)
                        {
                            KodiResponse itemResponse = kodi.getVideoItem(playerid);
                            txtTime.Text  = propertiesResponse.result.time.ToString();
                            txtField.Text = "File Name: " + itemResponse.result.item.file + Environment.NewLine
                                            + "Title: " + itemResponse.result.item.title + Environment.NewLine
                                            + "Season: " + itemResponse.result.item.season + Environment.NewLine
                                            + "Episode: " + itemResponse.result.item.episode + Environment.NewLine
                                            + "Show Title: " + itemResponse.result.item.showtitle + Environment.NewLine
                                            + "Album: " + itemResponse.result.item.album + Environment.NewLine
                                            + "Year: " + itemResponse.result.item.year + Environment.NewLine
                                            + "Type: " + itemResponse.result.item.type + Environment.NewLine
                                            + "Label: " + itemResponse.result.item.label + Environment.NewLine
                                            + "Artist: ";
                            foreach (String artist in itemResponse.result.item.artist)
                            {
                                if (artist != itemResponse.result.item.artist.Last())
                                {
                                    txtField.Text += artist + " -- ";
                                }
                                else
                                {
                                    txtField.Text += artist;
                                }
                            }
                            if (itemResponse.result.item.type == "movie")
                            {
                                txtToDisplay.Text = itemResponse.result.item.movieToString();
                            }
                            else if (itemResponse.result.item.type == "episode")
                            {
                                txtToDisplay.Text = itemResponse.result.item.episodeToString();
                            }
                            else if (itemResponse.result.item.type == "musicvideo")
                            {
                                txtToDisplay.Text = itemResponse.result.item.musicvideoToString();
                            }
                            else if (itemResponse.result.item.type == "unknown")
                            {
                                txtToDisplay.Text = itemResponse.result.item.unknownTypeToString();
                            }
                        }
                        else if (activePlayers.result[i].type == "audio" && activePlayers.result[i].playerid == playerid)
                        {
                            KodiResponse itemResponse = kodi.getAudioItem(playerid);
                            txtTime.Text = propertiesResponse.result.time.ToString();

                            //txtField.Text = kodi.getAudioItemJson();
                            txtField.Text = "File Name: " + itemResponse.result.item.file + Environment.NewLine
                                            + "Title: " + itemResponse.result.item.title + Environment.NewLine
                                            + "Album: " + itemResponse.result.item.album + Environment.NewLine
                                            + "Year: " + itemResponse.result.item.year + Environment.NewLine
                                            + "Type: " + itemResponse.result.item.type + Environment.NewLine
                                            + "Label: " + itemResponse.result.item.label + Environment.NewLine
                                            + "Artist: ";
                            foreach (String artist in itemResponse.result.item.artist)
                            {
                                if (artist != itemResponse.result.item.artist.Last())
                                {
                                    txtField.Text += artist + " -- ";
                                }
                                else
                                {
                                    txtField.Text += artist;
                                }
                            }
                            if (itemResponse.result.item.type == "song")
                            {
                                txtToDisplay.Text = itemResponse.result.item.songToString();
                            }
                        }
                        else if (activePlayers.result[i].type == "picture" && activePlayers.result[i].playerid == playerid)
                        {
                            KodiResponse itemResponse = kodi.getPictureItem(playerid);

                            //txtField.Text = kodi.getPictureItemJson();
                            txtField.Text = "File Name: " + itemResponse.result.item.file + Environment.NewLine
                                            + "Type: " + itemResponse.result.item.type + Environment.NewLine
                                            + "Label: " + itemResponse.result.item.label;
                            if (itemResponse.result.item.type == "picture")
                            {
                                txtToDisplay.Text = itemResponse.result.item.pictureToString();
                            }
                        }
                    }
                }
            }
        }