Ejemplo n.º 1
0
        /// <summary>
        ///     The callback to load the video.
        /// </summary>
        /// <returns></returns>
        IEnumerator StartVideo()
        {
            //Assign the Audio from Video to AudioSource to be played
            player.EnableAudioTrack(0, true);
            player.SetTargetAudioSource(0, audioSource);

            audioSource.volume = 1.0f;
            player.controlledAudioTrackCount = 1;
            player.Prepare();

            //Wait until video is prepared
            while (!player.isPrepared)
            {
                Debug.Log("Preparing Video");
                yield return(null);
            }

            Debug.Log("Done Preparing Video");

            // Disable Menu.
            menuFactory.SetActiveMenu(null);

            //Play Sound
            audioSource.Play();

            player.Play();
        }
Ejemplo n.º 2
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");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     The function to call when the streaming function is selected.
        ///     Create a menu with the list of the local video.
        /// </summary>
        /// <param name="name"></param>
        void ITvApp.ItemCallback(string name)
        {
            Menu fileMenu = menuFact.CreateMenu(TvMenuFactory.Type.TEXT_MENU, "FileMenu");

            // If the menu doesn't exist, create it.
            if (fileMenu != null)
            {
                string[] files = Directory.GetFiles(path);

                foreach (string file in files)
                {
                    if (supportedExtension.Contains(file.Substring(file.LastIndexOf(".") + 1)))
                    {
                        fileMenu.AddMenuItem(new Menu.MenuItem(Path.GetFileName(file), null, null), StartStreaming);
                    }
                }
            }

            // Show it.
            menuFact.SetActiveMenu("FileMenu");
        }
Ejemplo n.º 4
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);
        }