www.androidchunk.com

Hi Developer, Please visit www.androidchunk.com for Latest Updates. Thank you!

How To Embed YouTube Video In Android WebView?

Category: Android Codez  | Last Updates: 06/08/2017


Hey Android developer, In this tutorial we are going to Embed and Play YouTube Video in Android WebView.


Add WebView in Layout
First of all, Add WebView in layout xml file like below.
res/layout/activity_main.xml

Coding Activity
After that, Now just modify your relative java file, add myWebView.loadData and set first parameter as below

 "<html><body>Video From YouTube<br><iframe width=\"420\" height=\"315\" src=\"https://www.youtube.com/embed/EEmyesMbpGk\" frameborder=\"0\" allowfullscreen></iframe></body></html>"


Look at the full java code
src/TestActivity.java


Internet permission
Wait wait... 
Add Internet permission to AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET"/>


Also Read,
How to create Custom Toast In Android?
How to create Bitmap blur effect In Android?

Output:

1 comment :

  1. ERROR :GL_INVALID_OPERATION : glCreateAndConsumeTextureCHROMIUM: invalid mailbox name

    ReplyDelete