Force Video to Open in Youtube App on Android

Force video to open in Youtube app on Android

Here's how you can do that:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://" + id));
startActivity(intent);

The id is the identifier after the questionmark in the url. For example: youtube.com/watch?v=ID

Another way is:

Intent videoIntent = new Intent(Intent.ACTION_VIEW);
videoIntent.setData(url);
videoIntent.setClassName("com.google.android.youtube", "com.google.android.youtube.WatchActivity");
startActivity(videoIntent);

......

“href” value in HTML to open video in youtube app or market (Google Play) on Android

1) Intent solution :

<a href="
intent:
//8xn9iq3lG_w/
#Intent;
scheme=vnd.youtube;
package=com.google.android.youtube
S.browser_fallback_url=market://details?id=com.google.android.youtube;
end;
">youtube or market</a>

NB:

Maybe you need to remove spaces in href attribut:

<a href="intent://8xn9iq3lG_w/#Intent;scheme=vnd.youtube;package=com.google.android.youtube;S.browser_fallback_url=market://details?id=com.google.android.youtube;end;">youtube or market</a>

video


2) Link solution :

You get more information in Settings > Apps > Youtube > Open by default > Supported links:

  • youtube.be
  • m.youtube.com
  • youtube.com
  • www.youtube.com

See: https://youtu.be/8xn9iq3lG_w and try, here: http://output.jsbin.com/tubozokebe/

<a target="_blank" href="https://youtu.be/8xn9iq3lG_w">link: https://youtu.be/8xn9iq3lG_w</a> or
<a target="_blank" href="vnd.youtube:8xn9iq3lG_w">link: vnd.youtube:8xn9iq3lG_w</a>

video

Android - Open links in YouTube app by default

You should create a custom WebViewClient and override shouldOverrideUrlLoading.

This function is being called before the webview goes into the address. There, you should check if the link is a youtube link and if so, open an intent as user6363583 said, and return true, else return false.

Dont forget to set your custom Web client as your webview Web client... Just use: webview.setWebViewClient(yourClient)

How to force a video to play in fullscreen in youtube player?

Youtube v4.1.47 app cando it for you

intent.putExtra("force_fullscreen",true); 

I dont know about lower versions.

Android: How to force WebView to play a video from youtube?

i find the answer

    mWebview = (WebView) findViewById(R.id.mwebview);
mWebview.setInitialScale(1);
mWebview.getSettings().setPluginState(WebSettings.PluginState.ON);

mWebview.setWebViewClient(new WebViewClient()
{
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return true;
}
});


WebSettings webSettings = mWebview.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setAllowContentAccess(true);
webSettings.setEnableSmoothTransition(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setSupportZoom(false);
webSettings.setUseWideViewPort(true);
webSettings.setAppCacheEnabled(true);
webSettings.setSupportMultipleWindows(true);
mWebview.loadUrl("http://www.youtube.com/embed/" + video.youtube_id);


Related Topics



Leave a reply



Submit