I am trying to get the ThumbnailView working on my ArrayAdapter but I am getting the following error:
java.lang.IllegalStateException: Not connected. Call connect() and wait for onConnected() to be called.
at com.google.android.youtube.player.internal.r.i(Unknown Source)
at com.google.android.youtube.player.internal.o.k(Unknown Source)
at com.google.android.youtube.player.internal.o.a(Unknown Source)
at com.google.android.youtube.player.internal.p.<init>(Unknown Source)
at com.google.android.youtube.player.internal.ac.a(Unknown Source)
at com.google.android.youtube.player.YouTubeThumbnailView$a.a(Unknown Source)
My ArrayAdapter looks like this:
Code for ArrayAdapter
My xml video_items.xml Looks like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@drawable/listviewbox"
android:padding="10dp"
android:layout_height="match_parent">
<!-- Video Thumbnail -->
<com.google.android.youtube.player.YouTubeThumbnailView
android:id="@+id/imageView_thumbnail"
android:layout_width="85dp"
android:layout_height="85dp"
android:layout_alignParentLeft="true"
android:layout_margin="5dp"
android:background="@color/panelcolor"
android:scaleType="centerCrop" />
<!-- Video Title -->
<TextView
android:id="@+id/video_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView_thumbnail"
android:layout_toRightOf="@+id/imageView_thumbnail"
android:paddingBottom="5dp"
android:paddingRight="5dp"
android:text="@string/videotext"
android:textColor="@android:color/black"
android:textSize="16sp" />
</RelativeLayout>
What could be wrong here?
The same happened to me when showing YoutubeThumbnailView
s inside a long ListView. I found the solution mentioned f.e. here:
https://github.com/youtube/yt-android-player/issues/2#issuecomment-58913900
or here:
https://code.google.com/p/gdata-issues/issues/detail?id=7533#c6
The solution is wrapping the YoutubeThumbnailView
inside a ViewHolder
object, keeping track of its initialization state. The initialize(..)
method may not be called multiple times.
Unfortunately the exception doesn't lead there quickly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With