public void OnInitializationSuccess(IYouTubePlayerProvider provider, IYouTubePlayer player, bool wasResumed)
 {
     this.player = player;
     player.SetPlayerStyle(YouTubePlayerPlayerStyle.Chromeless);
     player.SetPlayerStateChangeListener(new VideoListener()
     {
         Loaded = () =>
         {
             state = State.VIDEO_CUED;
         },
         VideoEnded = () =>
         {
             state = State.VIDEO_ENDED;
             imageWallView.ShowImage(videoCol, videoRow);
             playerView.Visibility = ViewStates.Invisible;
         },
         Error = (errorReason) =>
         {
             if (errorReason == YouTubePlayerErrorReason.UnexpectedServiceDisconnection)
             {
                 // player has encountered an unrecoverable error - stop the demo
                 flipDelayHandler.RemoveCallbacksAndMessages(null);
                 state = State.UNINITIALIZED;
                 thumbnailLoader.Release();
                 thumbnailLoader = null;
                 player          = null;
             }
             else
             {
                 state = State.VIDEO_ENDED;
             }
         }
     });
     MaybeStartDemo();
 }
        public void OnInitializationSuccess(YouTubeThumbnailView thumbnailView, IYouTubeThumbnailLoader thumbnailLoader)
        {
            this.thumbnailLoader = thumbnailLoader;
            thumbnailLoader.SetOnThumbnailLoadedListener(new ThumbnailListener()
            {
                ThumbnailLoaded = (thumbnail, videoId) =>
                {
                    nextThumbnailLoaded = true;

                    if (activityResumed)
                    {
                        if (state.Equals(State.LOADING_THUMBNAILS))
                        {
                            FlipNext();
                        }
                        else if (state.Equals(State.VIDEO_FLIPPED_OUT))
                        {
                            // load player with the video of the next thumbnail being flipped in
                            state = State.VIDEO_LOADING;
                            player.CueVideo(videoId);
                        }
                    }
                },
                ThumbnailError = (thumbnail, reason) =>
                {
                    LoadNextThumbnail();
                }
            });
            MaybeStartDemo();
        }
Example #3
0
        public void OnInitializationSuccess(YouTubeThumbnailView view, IYouTubeThumbnailLoader loader)
        {
            loader.SetOnThumbnailLoadedListener(this);
            OnInitializationSuccessAction?.Invoke(view, loader);
            //thumbnailViewToLoaderMap.put(view, loader);
            view.SetImageResource(Resource.Drawable.loading_thumbnail);
            string videoId = (string)view.Tag;

            loader.SetVideo(videoId);
        }
 void IYouTubePlayerPlayerStateChangeListener.OnError(YouTubePlayerErrorReason errorReason)
 {
     if (errorReason == YouTubePlayerErrorReason.UnexpectedServiceDisconnection)
     {
         // player has encountered an unrecoverable error - stop the demo
         flipDelayHandler.RemoveCallbacksAndMessages(null);
         state = State.Uninitialized;
         thumbnailLoader.Release();
         thumbnailLoader = null;
         player          = null;
     }
     else
     {
         state = State.VideoEnded;
     }
 }
Example #5
0
        public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View       view  = convertView;
            VideoEntry entry = entries[position];

            // There are three cases here
            if (view == null)
            {
                // 1) The view has not yet been created - we need to initialize the YouTubeThumbnailView.
                view = inflater.Inflate(Resource.Layout.video_list_item, parent, false);
                YouTubeThumbnailView thumbnail = (YouTubeThumbnailView)view.FindViewById(Resource.Id.thumbnail);
                thumbnail.Tag = (entry.videoId);
                thumbnail.Initialize(DeveloperKey.DEVELOPER_KEY, thumbnailListener);
            }
            else
            {
                YouTubeThumbnailView    thumbnail = (YouTubeThumbnailView)view.FindViewById(Resource.Id.thumbnail);
                IYouTubeThumbnailLoader loader    = thumbnailViewToLoaderMap[thumbnail];
                if (loader == null)
                {
                    // 2) The view is already created, and is currently being initialized. We store the
                    //    current videoId in the tag.
                    thumbnail.Tag = (entry.videoId);
                }
                else
                {
                    // 3) The view is already created and already initialized. Simply Set the right videoId
                    //    on the loader.
                    thumbnail.SetImageResource(Resource.Drawable.loading_thumbnail);
                    loader.SetVideo(entry.videoId);
                }
            }
            TextView label = ((TextView)view.FindViewById(Resource.Id.text));

            label.Text       = (entry.text);
            label.Visibility = (labelsVisible ? ViewStates.Visible : ViewStates.Gone);
            return(view);
        }
 void YouTubeThumbnailView.IOnInitializedListener.OnInitializationSuccess(YouTubeThumbnailView view, IYouTubeThumbnailLoader loader)
 {
     this.thumbnailLoader = loader;
     thumbnailLoader.SetOnThumbnailLoadedListener(this);
     thumbnailLoader.SetPlaylist(PlaylistId);
 }
            void YouTubeThumbnailView.IOnInitializedListener.OnInitializationSuccess(YouTubeThumbnailView view, IYouTubeThumbnailLoader loader)
            {
                loader.SetOnThumbnailLoadedListener(this);
                thumbnailViewToLoaderMap.Add(view, loader);
                view.SetImageResource(Resource.Drawable.loading_thumbnail);
                var videoId = (string)view.Tag;

                loader.SetVideo(videoId);
            }
 void YouTubeThumbnailView.IOnInitializedListener.OnInitializationSuccess(YouTubeThumbnailView thumbnailView, IYouTubeThumbnailLoader thumbnailLoader)
 {
     this.thumbnailLoader = thumbnailLoader;
     thumbnailLoader.SetOnThumbnailLoadedListener(this);
     MaybeStartDemo();
 }