Example #1
0
        private void Init360Banner(ImmersiveBannerResultData[] banners)
        {
            if (banners.Length > 0)
            {
                GameObject ui = Instantiate(bannerPrefab, bannerContainer);
                btnPlayBanner = ui.transform.Find("BannerBtnPlay").GetComponent <Button>();
                btnPlayBanner.onClick.AddListener(OnClickPlayBanner);

                btnNextBanner = ui.transform.Find("BannerBtnNext").GetComponent <Button>();
                btnNextBanner.onClick.AddListener(NextBanner);

                btnPrevBanner = ui.transform.Find("BannerBtnPrev").GetComponent <Button>();
                btnPrevBanner.onClick.AddListener(PrevBanner);

                btnMuteBanner = ui.transform.Find("BannerBtnMute").GetComponent <Button>();
                btnMuteBanner.onClick.AddListener(MuteBanner);

                bannerPlaceholder.transform.SetAsLastSibling();
                StartCoroutine(HideBannerPlaceholder());
                isBannerReady = true;
            }
            else
            {
                return;
            }

            bannerMediaPlaylist.LoopMode = PlaylistMediaPlayer.PlaylistLoopMode.Loop;
            foreach (var item in banners)
            {
                MediaPlaylist.MediaItem it = new MediaPlaylist.MediaItem
                {
                    fileLocation = MediaPlayer.FileLocation.AbsolutePathOrURL,
                    filePath     = item.image,
                    autoPlay     = true,
                    startMode    = PlaylistMediaPlayer.StartMode.Immediate,
                    progressMode = PlaylistMediaPlayer.ProgressMode.BeforeFinish,
                };
                bannerMediaPlaylist.Playlist.Items.Add(it);
            }
            // Play first banner
            bannerMediaPlaylist.JumpToItem(0);

            btnPlayBanner.interactable = true;
            btnNextBanner.interactable = true;
            btnPrevBanner.interactable = true;
            btnMuteBanner.interactable = true;
        }
Example #2
0
        private void LoadPlaylist(string directoryPath)
        {
            if (Player.Control != null)
            {
                Player.Control.Stop();
            }

            if (directoryPath == null)
            {
                return;
            }

            Debug.Log("Israndomized = " + isRandomized);
            List <MediaPlaylist.MediaItem> items = new List <MediaPlaylist.MediaItem>();

            Player.CloseVideoExt();

            string[] files = Directory.GetFiles(directoryPath);

            if (isRandomized)
            {
                Debug.Log("Randomize playlist");
                Shuffle(files);
            }


            if (files.Length == 0)
            {
                return;
            }

            for (int i = 0; i < files.Length; i++)
            {
                string ext     = Path.GetExtension(files[i]);
                bool   isAudio = false;
                foreach (string e in SUPPORTED_AUDIO_EXT)
                {
                    if (e == ext)
                    {
                        isAudio = true;
                        break;
                    }
                }
                if (!isAudio)
                {
                    continue;
                }

                Debug.Log("Add to playlist : " + files[i]);
                MediaPlaylist.MediaItem mi = new MediaPlaylist.MediaItem();
                mi.fileLocation        = MediaPlayer.FileLocation.AbsolutePathOrURL;
                mi.filePath            = files[i];
                mi.autoPlay            = false;
                mi.startMode           = PlaylistMediaPlayer.StartMode.Manual;
                mi.progressMode        = PlaylistMediaPlayer.ProgressMode.OnFinish;
                mi.progressTimeSeconds = 0f;
                items.Add(mi);
            }

            //mpl.Items = items;

            Player.Playlist.Items = items;

            /*Player.PlaylistIndex = -1;
             * Player.NextItem();
             * Player.Play();
             */
            Player.JumpToItem(0);
        }