Device Info
Android Device: HUAWEI COL_AL10
Android Version: Android 9
Background
I develop an Android app to play YouTube video by YouTubeAndroidPlayerApi.jar, I choose native YouTube API instead of iFrame API.
Produce
Here is a Vertical-RecyclerView to display some YouTube Videos. I click the recyclerView's item and the video inside is to play, it's fine now.
Since I want to watch the YouTube Video in fullscreen mode, then I click the fullscreen button, trouble comes:
Summary
As soon as the fullscreen button clicked, the video playing ViewHolder in RecyclerView is detached and YouTube Player is released since the ViewHolder is removed or invalid said the RecyclerView.
However, my Activity is already landscape since YouTube fullscreen button clicked just now.
Why and how to fix?
Any suggestion will be appreciate.
guys
I finally solved the problem by code below:
youTubePlayer.setFullscreenControlFlags(0);
and then invoke Activity.setRequestedOrientation manually in onFullScreen callback.
That's it
Related
I have an activity with a YouTubePlayerSupportFragment within it to play youtube videos.
The youtube player's style is set to CHROMELESS (only video, no controls), and playback is controlled by my own custom play/pause button outside of the player's view. Every thing works as expected until the moment I leave the video activity for whatever reason and then come back to it.
Upon leaving the activity the video is paused - as expected - but after returning to it, requesting the player to player.play() does nothing. No errors nor exceptions, it just does nothing. Play() will only work again after I load a new video..
I've trying using YouTubePlayerFragment instead, but the result is the same. However, when using the DEFAULT style pressing the default play button will apparently reload the video (I see the buffer being flushed) from the previous position and work as expected. This leads me to believe that they're handling it somehow directly on their UI control code instead of on the player API..
I can reproduce this issue on the SDK's custom controls sample just by starting a video, pressing the recents key and returning to it so I think it's safe to assume that this is a bug..
Has anyone been able to work around this issue? is there any way to detect that the video needs to be reloaded while this isn't fixed?
Info: I'm using youtube's android player API v1.2.2 and the latest youtube app v10.49.59
After hours, the only solution I found was to save video position on Pause event and reload video (player.loadVideo) on PostResume event (when YouTubeFragment is resumed). But I don't known if this is the only/best solution.
I recently have updated YouTube Android Player API to 1.2.2 (the latest version), but it keeps telling me
16445-16445/com.* W/YouTubeAndroidPlayerAPI﹕ Cannot load modern controls UI. Upgrade to the latest version of the Android YouTube API.
, when I try to put a video on the fullscreen mode. In addition, the video stops playing and it appears, that it can’t be played anymore (it stucks). What’s even worse, when you press back, it does not allow you to play the video in normal mode, so, basically, you have to reload the activity. I’m using YoutubePlayerSupportFragment. I guess, that the general YouTube app update might have ruined it. I have noticed, that the full screen mode worked smoothly before.
How to overcome with this problem? Thanks in advance.
When you extend AppCompatActivity, It causes 2 following problems:
It causes error UNAUTHORIZED_OVERLAY when playing in fullscreen. Because the statusbar is on the top of YoutubePlayer.
Solution: set FULLSCREEN_FLAG_CUSTOM_LAYOUT to hide the status bar manually.
YouTubeAndroidPlayerAPI﹕ Cannot load modern controls UI. Upgrade to the latest version of the Android YouTube API.
The UI of YoutubePlayer looks so bad. It just happens when extending AppCombatActivity. Updating the latest youtube api doesn't work.
If you find the solution of the 2nd problem, please let me know.
I am using android-youtube api in my android project. I am using youtube fragment to play a youtube video.
Along with that video, I am playing other media (eg imageview) side-by-side. (I am aware that the youtube fragment should be always on top, so the problem is not related to this constraint).
I am able to play the video successfully, but the problem is, after video starts playing, the pause button does not fade out. It keeps showing that button. It seems like it fades out, but immediately after it disappears, it reappears.
I am not getting any logs related to this (not even in system log). However, when I play video fragment in full layout, there is no such problem.
In short, the problem occurs only when I play video along with some other media side-by-side. I didn't find any work around for this particular problem, so I don't have any code related to this problem.
How do I get rid of this issue?
Thanks in advance for help.
I am serving video's in a webview in Android using Appcelerator Titanium. On iOS this works like a charm. But on Android this gives some problems. It goes wrong the second time an activity is opened with a webview that holds a html5 video element.
Steps to reproduce:
(Also see this youtube video: http://www.youtube.com/watch?v=0MpSpfJNyOk )
The first time opening a video/activity with html5 video it shows the video and I am able to play it. When I close the window/activity and open a new window with another video the webview loads and the html5 video play loads as well. But playing it is not possible. When pressing the fullscreen button and pressing the play/pause button twice the video begins to play in fullscreen.
When pausing the video before closing the activity/window the video in the next window is able to play.
The youtube video shows the behavior on a Samsung Galaxy Tab 3 10.1" running Android 4.2 using this test project https://dl.dropboxusercontent.com/u/1849335/WebviewTest.zip
You can understand it took me a while to understand this pattern :)
Context:
I am using the 3.2.GA Titanium SDK with this fix (https://github.com/appcelerator/titanium_mobile/pull/5150) merged. In that change they fixed that the onPause() method should always be called on the webview when closing a activity otherwise the plugin processes will continue to play.
The files that are responsible for this behavior are:
https://github.com/wienke/titanium_mobile/tree/master/android/modules/ui/src/java/ti/modules/titanium/ui/widget/webview
https://github.com/wienke/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java
Curious if people also see this behavior without Titanium.
The solution was eventually provided in this question:
Android (Samsung S4) HTML5 video pauses
Adding this:
pause();
((AudioManager)activity.getSystemService(
activity.AUDIO_SERVICE)).requestAudioFocus(
new OnAudioFocusChangeListener() {
#Override
public void onAudioFocusChange(int focusChange) {}
}, AudioManager.STREAM_MUSIC,
AudioManager.AUDIOFOCUS_GAIN_TRANSIENT);
to the SDK onPause method here:
https://github.com/wienke/titanium_mobile/blob/master/android/modules/ui/src/java/ti/modules/titanium/ui/WebViewProxy.java#L427
fixed the problem.
I filed a defect to Appcelerator. Hope they include this soon in their SDK.
I have a problem with playinh youtube videos in my app.
I have a page with embed video. When i tap on video, loader appears, everything is ok.
When loader dissapears, it should start playing. But in my application there is white screen appears.
On LogCat at this moment i can see this:
CordovaLog showing Custom View
Problem fixed, by using plugin.
But, i have the same problem with VIMEO.
This plugin will help you to play a YouTube video in a Phonegap/Cordova app:
https://github.com/remcob00/cordova-phonegap_youtube_player_api_android