2013-04-17 8 views
11

Używam YouTubePlayer (API YouTube dla Androida) wewnątrz Fragment jestem pompowania LinearLayout z YouTube Player, w ten sposób:Android YouTubePlayer z nieuprawnionym nakładki na górze odtwarzacza

fragmentManager = getActivity().getSupportFragmentManager(); 
        fragmentTransaction = fragmentManager.beginTransaction(); 

        player = new YouTubePlayerSupportFragment(); 
        fragmentTransaction.add(R.id.youTubePlayerContainer, player); 
        fragmentTransaction.commit(); 

.. .W przypadku You TubePlayerContainer jest zawyżony LinearLayout

Odtwarzacz zostanie wykryty poprawnie, zacznie grać i będzie zatrzymywał się na sekundę. Rejestr zawiera następujące elementy:

YouTube video playback stopped due to unauthorized overlay on top of player. 
The YouTubePlayerView is obscured by [email protected] 
YouTubePlayerView is completely covered, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 484, top: 100, right: 100, bottom: 170.. 

To jest mój XML: (Nie FrameLayout w nim)

<LinearLayout 
     android:id="@+id/curtain" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:id="@+id/withApi" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <LinearLayout 
       android:id="@+id/youTubePlayerContainer" 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_gravity="center" 
       android:layout_margin="30dp" 
       android:layout_weight="1" 
       android:orientation="vertical" > 
      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_margin="3dp" 
       android:background="@color/trans_popUp" 
       android:padding="3dp" > 

       <TextView 
        android:id="@+id/textYouTubeVisor" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="Title..." 
        android:textColor="@color/white" /> 
      </LinearLayout> 
     </LinearLayout> 

Próbowałem zmianę marginesów bez powodzenia. czytam oficjalnej dokumentacji, ale bez powodzenia Wskazuje, że FrameLayout że przyczyną problemu jest: android.widget.FrameLayout @ 4110d1f8 Ale z takiego odniesienia nie identyfikuje który odnosi

komuś, że to się stało?

Doceniam każdą pomoc.

Pozdrowienia

+2

Odtwarzacz został zaprojektowany w taki sposób, aby nie można było niczego umieścić nad zawartością lub elementami sterującymi. Ponieważ nie uwzględniłeś odtwarzacza w swoim układzie, mogę tylko założyć, że układ pojawia się nad wideo, a nie pod nim. Czy widzisz swój tytuł ... podczas gry? –

+1

Czy rozwiązałeś problem? Plz dał mi znać, utknąłem tutaj :( – Reyjohn

+0

@Reyjhon Nie udało mi się rozwiązać tego problemu.Jeżeli znajdę rozwiązanie, wyjaśnię, jeśli znajdziesz, będę wdzięczny za poinformowanie mnie. Pozdrowienia – Sergio76

Odpowiedz

1

Kod demo Android API wykorzystuje ten układ do demo fragment, który może może dostać pomysły dzieje. Zobacz tę stronę: https://developers.google.com/youtube/android/player/

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical"> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:textAppearance="@android:style/TextAppearance.Small" 
     android:gravity="center" 
     android:text="@string/playerfragment_text"/> 

    <fragment 
     android:name="com.google.android.youtube.player.YouTubePlayerFragment" 
     android:id="@+id/youtube_fragment" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"/> 
</LinearLayout> 
4

Problem jest tylko z układzie, YouTube Player nie dopuszcza żadnego widoku pobyt nad nim, ani niewidoczny ani przejrzyste.

Aby to widoczne w urządzeniu włącz granic układu w wariancie deweloperskim. (Ostrzeżenie z paddings i margins)

spróbować wykomentuj kod others poglądów na układ i przetestować ponownie proszę.

2

Odtwarzacz Youtube znaleźć niektóre widoki nakładki. Po prostu usuń te widoki lub setVisible (View.GONE) dla nich. Proszę sprawdzić ten link, aby uzyskać więcej informacji. Solution

13

Czy byłeś w stanie rozwiązać ten problem?

I w obliczu tego samego problemu dzisiaj, a dla mnie błąd w dziennikach był:

W/YouTubeAndroidPlayerAPI﹕ YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor com.google.android.youtube.player.YouTubePlayerView{42686bc8 V.E..... ........ 0,0-1200,675 #7f0a00a0 app:id/video_player}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: -10, top: -10, right: -10, bottom: -10 (these should all be positive). 

naprawiłem to przez usunięcie wyściółkę w YouTubePlayerView w układzie. Mój układ wygląda następująco:

<com.google.android.youtube.player.YouTubePlayerView 
    android:id="@+id/video_player" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#000" /> 
+0

To rozwiązało mój problem , dziękuję bardzo za podzielenie się tym! –

+0

To była jedyna rzecz, której potrzebowałem ... dziękuję :) –

+0

Pomógł mi również. Dodatkowy info- błąd wystąpił także podczas przewijania strony, na której znajduje się YouTubePlayerView. Kiedy YouTubePlayerView staje się niewidoczny (w mt przypadku z powodu przewijania aktywności), wideo zatrzymało się z tym błędem – user2924714

1

Musisz usunąć dowolny atrybut padding w widoku Wideo.

Źle:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <com.google.android.youtube.player.YouTubePlayerView 
    android:id="@+id/youtube_player" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    **android:padding="10dp"** /> 

    </LinearLayout> 

prawej:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <com.google.android.youtube.player.YouTubePlayerView 
    android:id="@+id/youtube_player" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    /> 

    </LinearLayout> 
1

Miałem ten sam błąd. Chociaż zrobiłem zmiany XML, nadal otrzymywać błąd:

YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by android.view.View{59fa6ce V.ED..... ........ 0,0-1440,84 #102002f android:id/statusBarBackground}. The view is inside the YouTubePlayerView, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 0, top: 0, right: 0, bottom: 2308.. 

Po ustawić pełnoekranowym, to działało idealnie

getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); 

nadzieję, że pomoże innym.

+0

Tak, pomogło! :): D –

Powiązane problemy