So currently, I've pre-defined URL which I pass to WebView and user is able to watch the video. Problem is that user can also use "search" and switch to other videos after watching the one I defined. Is there a possibility to limit user to watch only one video (while keeping possibility to mute/pause/play video)? Or do I have to implement some Video Player for this use-case?
webView.settings.javaScriptEnabled = true
webView.settings.useWideViewPort = false
webView.loadUrl(url)
Unfortunately it looks like it's no longer possible to hide the video information and related videos when using an embedded player. For more information on why YouTube removed this see https://developers.google.com/youtube/player_parameters#release_notes_08_23_2018
I suggest you take a look at the YouTube Android Player API and try the YouTubeStandalonePlayer or implement YouTubePlayerFragment or YouTubePlayerView.
Related
We want to play some YouTube videos in my React Native app without YouTube branding. We would like to give the user experience as if the video is playing in a native player. We already tried with webview, react-native-youtube-iframe but still, we are not able to achieve our goal. Either top or bottom section has a YouTube logo, then watch and share options are visible. We want to eliminate those. Any possible way to do this in React Native?
URLs of Youtube videos are different for normal videos and embedded videos.
Normal: https://www.youtube.com/watch?v=DGQwd1_dpuc
Embed: https://www.youtube.com/embed/DGQwd1_dpuc
Please change 'watch?v=' with '/embed/'.
You can also hide controls and information by passing 'showinfo=0' or 'controls=0'.
I recently tried to achieve the similar thing in one of my android app if you can somehow use this particular library
This is an android library and as you mentioned you want to do it in android.
android-youtube-player
I have used this library where i used a player with custom control which helps you override the controls and also this share and next button and even the youtube logo.
Let me know if you need any help further.
Edit:
To enable web UI
IFramePlayerOptions options = new IFramePlayerOptions.Builder().controls(1).build();
Then initialize the player with this controls.
You won't see any logo now.
I am working on developing an in house API that plays some audio. Essentially, I need to drop some embed code in to my application which provides a play/pause button and plays some audio.
I am using a WebView to embed this code in my application. The player seems to appear in the application although when clicking play, I am getting an error the says Play() can only be initiated by a user gesture.
I understand why I am getting this error and why its important to wait for a user gesture. I'd like to adjust my embed code to meet this functionality but am not clear on what I can do to resolve this error and play the audio. Currently, the audio doesn't automatically begin to play, the user must click the play button in the embed code.
Also, whats a bit odd, is that embedding a YouTube video works fine, I am curious as to why YouTube embeds work while my embed doesn't.
The problem in here is in the code embed, not with react-native. Webview has a property called mediaPlaybackRequiresUserAction wich is true by default, try setting it to false to see if it helps
I want to display YouTube video in my android application with the parameter modestbranding=1 and showinfo=0 in webview. When I tried this,then modestbranding doesn't work any more.
if i remove showinfo then modestbranding parameter is working and vice versa.
https://www.youtube.com/embed/ANdeRJF7MWo?modestbranding=1&showinfo=0&rel=0
I search alot but did not find its solution. Please help
Here are the IFrame player docs with the officially supported parameters along with revision history
modestbranding - This parameter lets you use a YouTube player that does not show a YouTube logo. Set the parameter value to 1 to prevent the YouTube logo from displaying in the control bar. Note that a small YouTube text label will still display in the upper-right corner of a paused video when the user's mouse pointer hovers over the player.
showinfo - was deprecated in 2018
See Also:
modestbranding not working for YouTube embed
About Youtube iframe caption ,title, modestbranding problem
How can I remove the youtube branding completely from embedded video?
In my app I'm using YouTube Android Player API library from here https://developers.google.com/youtube/android/player/
I have a fragment that extends YouTubePlayerFragment. All works fine, but I need to make some improvements to app.
At the end of some videos I see block "Watch Next" with the link to another video, so I'm curious - does we have a possibility to disable this feature?
I created another solution using WebView, and display video using it - in this case I'm able to turn off any other additional links using "rel=0" in video url, but I want to use native solution.
Any ideas?
Thanks in advance!
Hi I have a website that has a video player in it, and I want to play that video player insie of my android application. The video player plays great inside of the androids native browser, But when I direct a WebView to go to that same site with the player the video player doesn't show up, All the content around the player shows up. How do I get the video player to play inside of my applications webview?
Webview will not by default allow Javascript which is most likely what your video player is using on the website. You would most likely need to tell your Webview to use Javascript in order for it to at least try to play the video (I say try because I have never done this myself, I usually use a player activity for video).
So by referencing your activies webview object you can do this:
browser = (WebView) findViewById(R.id.webbrowser_wvViewer);
browser.getSettings().setJavaScriptEnabled(true);
Are you sure your video codec is compatible with Android webview ?
Depending on the browser, the required video codec is different.
You can also check this links to debug and see the exact error :
http://www.smartjava.org/content/remote-chrome-debugging-android
Christian,
What version of the Android OS are you testing this on?
In Android version Gingerbread and earlier, your WebView based app must implement the WebChromeClient callback in order to be able to play videos. Here is the documentation for WebChromeClient:
http://developer.android.com/reference/android/webkit/WebChromeClient.html
Specifically, look at the onShowCustomView() and onHideCustomView callbacks. When playing a video the WebView will callback the onShowCustomView() of the WebChromeClient implementation that you provide. The first param in this callback is a view - which is actually the video that you want to display. The app is expected to override this callback and add this view to the application's window. To summarize, your steps will be as follows:
1. Create a WebView in your app, implement the WebChromeClient in your app and register it using WebView.setWebChromeClient(this).
2. Now your app's onShowCustomView will be called when the user selects play on the video.
3. In your app's implementation of onShowCustomView() you can replace the WebView that is currently displayed by the new View. Do the reverse on onHideCustomView callback.
The default implementation for this method is to ignore which is why you are not seeing the video play in your app.