I am trying to place a YouTubePlayerSupportFragment within a SlidingDrawer view. However, when it runs the video is stopped after 1 second and the follow is posted in LogCat:
W/YouTubeAndroidPlayerAPI(1778): YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is obscured by ViewName{41726520 V.E..... ........ 0,0-720,1038 #7f060040 app:id/drawer}. YouTubePlayerView is completely covered, with the distance in px between each edge of the obscuring view and the YouTubePlayerView being: left: 0, top: 241, right: 0, bottom: 392..
The SlidingDrawer is opened and the video is completely visible and not obscured. Does anyone know a solution to this?
Thanks
I had the same issue, I was changing the margins of the YouTubePlayerSupportFragment,where the distance was negative until it worked. Not sure why this happens though.
from ducumentation youtube player shoudbe topest element and have minimal size of 200*110 dp. If it is smaller - player will stop. If any view (even invisible) will overlap the youtube player - player will stop
Related
Im developing video app for TV boxes. For SurfaceView (shows video from android MediaPlayer) with "stretch vertically" display mode the same coordinates for both boxes are calculated by algorythm. For example result is: left: -960, top: 0, right: 960, bottom: 1080, then it passed to the mySurfaceView.layout(left, top, right, bottom).
On two different boxes (both android 7 and one resolution 1920x1080) I have different behavior: the first crops picture (I need this behavior)
and the second compresses picture.
layout:
<FrameLayout >
<custom RelativeLayout match_parent>
<SurfaceView by addView() />
<RL/>
<FL/>
tried:
clipChildren = false for all parent views
mediaPlayer.setVideoScalingMode(...with_cropping)
I have a custom VideoView, I'm overriding onMeasure method to make video fill the screen, while keeping proportions of the video file.
Everything works fine, but with some videos, it has a strange behaviour:
I put an interrupt point in onMeasure method and run in debug mode.
When video loads, it fills the screen as expected, but after some seconds, exactly when the mouse pointer disappears, the video resizes to its original size, not filling the screen, and without passing again over the interrupt point (onMeasure method is not called).
If I move the mouse again, the video fills the screen until the pointer disappears.
I'm using Android 4.4.4.
In case someone has the same problem, I'll post what I did:
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getRealMetrics(metrics);
FrameLayout fralayout = (FrameLayout) findViewById(R.id.framelayoutparent);
FrameLayout.LayoutParams lpFraParams = (FrameLayout.LayoutParams) fralayout.getLayoutParams();
lpFraParams.width = metrics.widthPixels-1;
lpFraParams.height = metrics.heightPixels-1;
fralayout.setLayoutParams(lpFraParams);
Previously I didn't substract one pixel to width and height, substracting one pixel did the trick. This FrameLayout is the parent of the VideoView.
I don't understand why it had that behaviour.
I'm using Youtube Api for Android in my app, and i create new YouTubePlayerView dynamic in my activity such as:
YouTubePlayerView youTubePlayerView = new YouTubePlayerView(PlayerActivity.this);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(640, 360);
layoutParams.setMargins(100, 200, 0, 0);
youTubePlayerView.setLayoutParams(layoutParams);
root.addView(youTubePlayerView);
As the code, "root" is a RelativeLayout, and the size and margin of youTubePlayerView is different with each youTubePlayerView;
this code sometimes work, but sometimes not, it returns error below:
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{37ab2582 V.E..... ......ID 0,0-0,0}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: 0, top: 0, right: 0, bottom: 0 (these should all be positive).
or this one
W/YouTubeAndroidPlayerAPI: YouTube video playback stopped due to the player's view being too small. The YouTubePlayerView is 0dp wide (minimum is 200dp) and 0dp high (minimum is 110dp).
is there any way to avoid it happen, or let it play video successfully.
i appreciate any help.
Regards
Based on the Official Google Documentation, setting the flag leaves to you the task of handling the UI elements visibility.
YouTube player will detect that a view is being displayed over it and will throw that warning.
You can try with one of the following additional flags:
FULLSCREEN_FLAG_ALWAYS_FULLSCREEN_IN_LANDSCAPE:causes the player to automatically enter fullscreen whenever the device enters landscape orientation.
FULLSCREEN_FLAG_CONTROL_ORIENTATION: enables automatic control of the orientation.
FULLSCREEN_FLAG_CONTROL_SYSTEM_UI: enables automatic control of system UI.
FULLSCREEN_FLAG_CUSTOM_LAYOUT:disables the default fullscreen layout handler, enabling you to control the transition to fullscreen layout manually.
Hello I worked on a GLTextureView to display an alpha video, but because of the alpha channel I setted
setEGLConfigChooser(8, 8, 8, 8, 16, 0);
I tried a first time with a GLSurfaceView but the problem was that it needed a setZOrderOnTop(true)to show it and the view wasn't anymore attached to it's container (which is a zoomView).
A TextureViewis better but now I've my video in a hole rectangle on my container sadly!
Source:
wanted
--[EDIT]--
Here some exemple :
On top it's an GLSurfaceView with an alpha video and down a custom GLTextureView, both are in an horizontalView.
Top appears to be good as I want! But check this when I scroll to right:
Top still appear when bottom hide as it needed!
When youtube player fragment nested in ScrollView I get error when rotate device to landscape:
YouTubePlayer.ErrorReason.UNAUTHORIZED_OVERLAY
And what is more interesting, is that the problem disappears when I remove ScrollView! But I can
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
/>
<fragment
android:name="com.google.android.youtube.player.YouTubePlayerFragment"
android:id="#+id/youtubeplayerfragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
YouTubePlayer.ErrorReason.UNAUTHORIZED_OVERLAY error indicates that *Playback has been stopped due to a view overlaying the player. This means that the YouTube Player has been obscured by some other view on top of it. The YouTube API can detect it and stop the Playback.
One very common reason for this to happen is when the fragment for holding the YouTube player is embedded in a scroll view. Scroll View adds additional layer of elements can be be scrolled. For.eg the in your case. The player contained in the same declaration would detect the overlap and would eventually stop giving the above error.
I have the same problem with a YoutubePlayer inside of a ScrollView and it stops with this message:
W/YouTubeAndroidPlayerAPI: YouTube video playback stopped due to unauthorized overlay on top of player. The YouTubePlayerView is not contained inside its ancestor android.widget.ScrollView{69b88e5 VFED.V... ........ 0,0-1794,1017 #7f0d0070 app:id/scrollview}. The distances between the ancestor's edges and that of the YouTubePlayerView is: left: 21, top: 196, right: 21, bottom: -164 (these should all be positive).
This happens all the time when the video is not fully visible on the screen. When it is visible completely, rotating the device works fine. To me this looks like a bug in the Youtube Android Player. I made a workaround with the following code:
#Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// This is an ugly workaround to prevent youtube from (wrongly) thinking we have an
// overlay above the video. Having overlays is not allowed and the video would stop otherwise.
DisplayMetrics metrics = getResources().getDisplayMetrics();
int offset = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, metrics);
scrollView.scrollTo(0, youtubePlayer.getView().getTop() - offset);
}
This obviously is not a good fix, because it depends on the ratio of the video and how it is shown on your display. Also your ScrollView will be scrolled to a different place after rotation (which you could re-reset manually later on).