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.
Related
I'm developing a social media app which has feed tab based on RecyclerView. On that feed tab I have many types of feedtype like text, photo, photo and text, book, etc... So till now I didn't had any problem about this. On my view holder I've Middle Item Container Panel. I'm putting template which is coming from my feedtypemanager class. So now I need to add videoview for my video feeds. First problem is I'm using rtsp server for streaming. VideoView starting after 15 seconds from seeing that view. Second one is when I scroll down and come up again my VideoView starting from beginnging and I'm waiting 15 seconds again to play that video. So how can I do that view like Instagram fast ? Which protocol I should use and Which VideoPlayer ? Thanks for help.
I've faced the same issues with videoview,
I would recommend to use Exomedia library and make your life easy with that.
For smooth video playback use some caching mechanism.
I would recommend AndroidVideoCache Library.
Use app:useTextureViewBacking="true" for smooth animations and transitions of videoview.
On Video players such as Youtube, I often see that when the user taps on the video view a sort of overlay shows up where the user can choose actions like: “share”, “add to playlist”, “pause”, etc. Basically it’s whatever the developer wants. The developer seems to be able to choose what the icons are, where they go, etc.
I would like to know how it’s done. For example, are they using a VideoView with an overlay? Are they using a FrameLayout with a VideoView and a RelativeLayout on top of the VideoView? I just need some advice in the right direction as I don’t know where to start. Thanks. For simplicity, I am looking to add a Youtube style video player to my activity. And by Youtube style, I am referring to the aforementioned interactions.
I would like to know how it’s done
I am sure that the implementation varies widely.
For example, are they using a VideoView with an overlay?
AFAIK, few professional-grade apps use VideoView, simply because VideoView offers little in the way of events or control. More likely, they are using something else backed by MediaPlayer or third-party media libraries (e.g., ExoPlayer).
Are they using a FrameLayout with a VideoView and a RelativeLayout on top of the VideoView?
No, because that would be two VideoView widgets. However, whatever their video surface is probably resides in a RelativeLayout or FrameLayout, with the overlay as another child of that same container, though I am sure that there are other approaches.
You are welcome to use uiautomatorviewer to try to learn more about the view hierarchy of particular apps of interest.
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
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);
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.