2013-04-17 6 views
11

मैं YouTubePlayer (Android के लिए YouTube एपीआई) का उपयोग कर रहा की चोटी पर अनधिकृत ओवरले एक टुकड़ा भीतर के साथ मैं यूट्यूब प्लेयर के साथ एक LinearLayout बढ़ा-चढ़ाकर कर रहा हूँ, इस तरह से:एंड्रॉयड YouTubePlayer खिलाड़ी

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

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

.. जहां youTubePlayerContainer inflated LinearLayout

प्लेयर सही ढंग से पता चला है, खेलना शुरू कर रहा है और दूसरी स्टॉप में है। लॉग निम्नलिखित पता चलता है:

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.. 

यह मेरा एक्सएमएल है: (यह के भीतर कोई FrameLayout)

<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> 

मैं सफलता के बिना मार्जिन को बदलने की कोशिश की। मैं आधिकारिक दस्तावेज पढ़ लेकिन सफलता नहीं मिली इंगित करता है कि FrameLayout है कि समस्या का कारण बनता है: android.widget.FrameLayout @ 4110d1f8 लेकिन इस तरह के एक संदर्भ जो दर्शाता है

किसी वह हुआ करने के लिए

की पहचान नहीं करता है?

मैं किसी भी मदद की सराहना करता हूं।

सादर

+2

प्लेयर डिज़ाइन किया गया है ताकि आप सामग्री या नियंत्रण पर कुछ भी नहीं डाल सकें। चूंकि आप अपने लेआउट में प्लेयर को शामिल नहीं करते हैं, इसलिए मैं केवल यह मान सकता हूं कि लेआउट वीडियो पर आ रहा है, न कि इसके तहत। क्या आप अपना शीर्षक देख सकते हैं ... खेल रहे हैं? –

+1

क्या आपने इस मुद्दे को हल किया? कृपया मुझे बताएं, मैं यहां फंस गया हूं :( – Reyjohn

+0

@ रेज़हॉन मुझे यह हल नहीं हुआ। अगर मुझे कोई समाधान मिल जाए, तो मैं समझाऊंगा। अगर आपको कोई मिल जाए, तो मैं आपको बताने के लिए सराहना करता हूं। – Sergio76

उत्तर

1

एंड्रॉयड एपीआई के लिए डेमो कोड टुकड़ा डेमो के लिए इस लेआउट का उपयोग करता है, शायद कि विचारों जा रहा प्राप्त कर सकते हैं। यह पेज देखें: 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

समस्या केवल लेआउट के साथ है, YouTube Player इस पर रह किसी भी दृश्य, न तो अदृश्य है और न ही पारदर्शी अनुमति नहीं देता है।

आदेश यह आपके डिवाइस में दृश्यमान बनाने के लिए डेवलपर विकल्प में लेआउट सीमाएं सक्षम हैं।

कोशिश (paddings और margins साथ चेतावनी) अपने लेआउट पर अन्य लोगों के विचारों 'कोड बाहर टिप्पणी और कृपया फिर से इस परीक्षण करने के लिए।

2

यूट्यूब प्लेयर कुछ विचारों को ओवरले करते हैं। बस उन दृश्यों को हटा दें या उनके लिए दृश्य (View.GONE) सेट करें। कृपया अधिक जानकारी के Solution

13

के लिए इस लिंक की जाँच आप इस समस्या को हल करने में सक्षम थे?

मैं आज एक ही समस्या का सामना करना पड़ा, और मेरे लिए लॉग में त्रुटि थी:

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). 

मैं लेआउट में YouTubePlayerView में गद्दी निकाल कर इस तय की। तो मेरी लेआउट इस तरह दिखता है:

<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

इस मुद्दे को हल करता है , इसे साझा करने के लिए आपको बहुत बहुत धन्यवाद! –

+0

यह एकमात्र चीज की जरूरत थी ... धन्यवाद :) –

+0

मुझे भी मदद की। अतिरिक्त जानकारी- पेज स्क्रॉल करते समय त्रुटि भी हुई, जिस पर YouTubePlayerView स्थित है। जब YouTubePlayerView अदृश्य हो जाता है (गतिविधि पर स्क्रॉल के कारण एमटी मामले में), वीडियो इस त्रुटि के साथ – user2924714

1

आप वीडियो दृश्य में किसी भी गद्दी विशेषता निकालना होगा।

गलत:

<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> 

अधिकार:

<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

मैं एक ही त्रुटि थी। हालांकि मैं एक्सएमएल परिवर्तन किया था, मैं त्रुटि प्राप्त करना जारी रखा: मैं फुल स्क्रीन सेट करने के बाद

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.. 

, यह काम सही

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

आशा है कि यह दूसरों की मदद करेगा।

+0

हाँ मदद की! :): डी –

संबंधित मुद्दे