Exemplo n.º 1
0
        /// <summary>
        ///     The function to call when the twitter application is selected.
        /// </summary>
        /// <param name="name"> "Twitter app" </param>
        void ITvApp.ItemCallback(string name)
        {
            // Deactivate menu.
            menuFact.SetActiveMenu(null);

            Menu tweets = menuFact.CreateMenu(TvMenuFactory.Type.SOCIAL_MENU, "TwitterMenu");

            if (tweets != null)
            {
                // Show twitters
                TwitterInterface.GetTwitters(display.transform.parent.GetComponent <SmartTv>(), 20, (bool success, string response) => {
                    if (success)
                    {
                        TwitterResponse tresponse = JsonUtility.FromJson <TwitterResponse> (response);

                        // Print the tweets and their author.
                        for (int i = 0; i < tresponse.items.Length; ++i)
                        {
                            // display.transform.parent.GetComponent<SmartTv>().StartCoroutine(DownloadImage(tresponse.items[i].user.profile_background_image_url, image));

                            string [] fields   = { tresponse.items[i].user.name, tresponse.items[i].text };
                            Menu.MenuItem item = new Menu.MenuItem();
                            item.name          = "tweet" + i;
                            item.fields        = fields;
                            tweets.AddMenuItem(item, (string nm) => {});
                        }

                        menuFact.SetActiveMenu("TwitterMenu");
                    }
                    else
                    {
                        Debug.Log(response);
                    }
                });
            }
            else
            {
                menuFact.SetActiveMenu("TwitterMenu");
            }
        }
Exemplo n.º 2
0
        // Use this for initialization
        void Start()
        {
            // Creates component to render video.
            display = transform.Find("Display").gameObject;

            closeVideo = false;
            RenderTexture texture = new RenderTexture(1024, 720, 24);

            display.GetComponent <Renderer>().material.SetTexture("_MainTex", texture);
            audioSource = display.GetComponent <AudioSource>();
            player      = display.AddComponent <VideoPlayer>();

            player.playOnAwake      = false;
            audioSource.playOnAwake = false;

            //Set Audio Output to AudioSource
            player.audioOutputMode = VideoAudioOutputMode.AudioSource;

            // Cretes panel menu.
            menuFactory = GetComponent <TvMenuFactory>();
            apps        = new List <ITvApp> {
                new TvLocalStreaming(menuFactory, PlayVideo),
                new TvTwitter(display, menuFactory)
            };

            Menu currMenu = menuFactory.CreateMenu(TvMenuFactory.Type.PANEL_MENU, "main");

            foreach (ITvApp app in apps)
            {
                currMenu.AddMenuItem(new Menu.MenuItem(app.GetName(), app.GetTexture(), null), app.ItemCallback);
            }

            menuFactory.SetActiveMenu("main");

            // Go back in Menu view.
            KeyboardHandler.AddCallback(KeyboardHandler.Map.KEY_DOWN, KeyCode.Escape, menuFactory.GoBack);
            KeyboardHandler.AddCallback(KeyboardHandler.Map.KEY_DOWN, KeyCode.D, NextTab);
            KeyboardHandler.AddCallback(KeyboardHandler.Map.KEY_DOWN, KeyCode.A, PreviousTab);
        }