Error messages displayed within the YoutubePlayerView - android

I'm embedding a youtube player within my android application.
When an error occurs while loading a youtube video with the android player, a textual message is displayed within the YoutubePlayerView.
I want to retry loading the video until a specific timeout is reached.
Is there a way to avoid that behavior (the visual notifications of errors within the YoutubePlayerView) ?

I don't think this can be done via the YouTube SDK.
What you can do is this
Override YouTubePlayer.PlayerStateChangeListener.onError and YouTubePlayer.PlayerStateChangeListener.onLoaded
When an error occurs (onError is triggered), simultaneously hide the YouTubePlayerView and show a black View on top of it (with a loading ProgressBar, eventually)
If the video loads correctly (onLoaded is triggered), hide the black View and show the YouTubePlayerView

Related

How to scale/crop Youtube video in Android?

I'm using YouTubePlayerView of YouTube Android Player API. I just want to get the center view of the video like this:
Is there anyway to do that ?
You can't crop a video while playing via the android youtube-player-api. You also can't hide any part of the video by overlaying another view on top of it or the player will throw UNAUTHORIZED_OVERLAY Error.
So if you ever try to hide the player by putting a View or two on either side then you can't. However there is one way to cover the YouTubePlayerView: Dialog and DialogFragment, you can put up either a Dialog or DialogFragment add some views and cover the video partially to give that special crop effect. From these two IMO DialogFragment is the better choice (you may feel differently).
Another way to crop the video would require complete change of player on your part. You'd have to switch to a WebView based player i.e. play your videos in a literal browser (there are lots of WebView-based players available on github). A WebView unlike YoutubePlayerView or YoutubePlayerFragment will not throw the nasty UNAUTHORIZED_OVERLAY Error. However you will see ads and the default player controls while the video is being loaded. I guess you might be able to hide the WebView or overlay another view on top of it while the video is loading and use the YouTube Data API to put a thumbnail on top, but I've never tried it.

Youtube API - Touch Event Passed to Views Behind Youtube Player

I am using a YoutubeAndroidPlayerAPI in my Android App.
In my YouTubePlayerSupportFragment I am setting youtubePlayer.addFullscreenControlFlag(YouTubePlayer.FULLSCREEN_FLAG_CUSTOM_LAYOUT); so that I can change between Fullscreen without having to rebuffer each time I do so.
For that I removed the navigation bar please see my previous SO question about it. So now the player is playing fine. But somehow the touch events are passing down behind the player (i.e. to views behind youtube player) but Only when touch events are below the player's SeekBar (In FullScreen Mode).
Is there any workarounds to this problem?
Any one knows of any open issues regarding this issue?
Try adding android:clickable="true" to the top ViewGroup of your fragment's layout file.

Android Video view ceating black window while make it gone

My application has several pages of book. In some of page I am playing video using video view. I am checking if I have any video for that page. If yes, than I am making videoview visible and passing Uri. If not, I am making it gone.
Now the problem is, once i reached to that screen and then if I swipe left/right it's creating black window in every subsequent screen. Why?
I found solution. When you want to show video make videoView.setZOrderOnTop(false); and when you want to hide video view jusr make videoView.setZOrderOnTop(true);

Android VideoView Update Subtitles

I'm trying to make a video player with VideoView that supports subtitles using a TextView on top of it.
I've already parsed the subtitles but now i need an event that runs every time a frame changes or so to update the subtitles with the current playing position.
I tried making a thread but I am not able to change my TextView in that separate thread. Is there an event on VideoView/MediaPlayer that runs every frame change that I can override to call my updateSubtitle method?
Starting with Android 4.4 , you can put subtitles from within the VideoView itself:
https://www.youtube.com/watch?v=hCRGc2PcmB8#t=130
Coming to your first question, there is no event that happens each video frame. Having said that there are ways of getting current time and synchronize subtitles to the current time. Below links might be of help
A white paper on how to support subtitles in Android

Video playing in webview always hiding other views?

I have a webview that's playing a video, and I want it to appear behind some other views, but I can't seem to make it happen. I've tried simply just sending the foreground views to the front with bringChildToFront(View v), but no cigar. Any thoughts?
Edit: Some more details: The webview plays a video using flash, and the webview is the size of the entire screen. I have some stuff I want to pop up in front of the video, but they only stay behind the video. They're definitely there, as they receive touch events and stuff, but just hidden away from view by the video.
Since the Flash player will essentially pre-empt any other views in the window, you'll just have to do one better over Flash: use another window on top of the main window.
Android allows you to do this by using the PopupWindow class.

Categories

Resources