Youtube Movie in WebView

margret

Well-Known Member
Licensed User
Longtime User
Does anyone know how to start a youtube video in full screen mode in a webview? It's easy to start the movie WebView.LoadURL("link here"), but I am looking to start it in full screen without the user having to mess with the screen. Also, it would be nice to lock it to view say 360 res even if the movie is posted with options for 480p, 720p, etc. Any information would be helpful.:sign0085:

Thanks,

Margret
 

Inman

Well-Known Member
Licensed User
Longtime User
You can use the Youtube app to play the video, instead of Webview. That also won't open in full screen by default but at least the user knows all he needs to do is tilt the phone to landscape mode to get full screen.

You can open a video in the Youtube app using Intents

A Programmer's Ride: Android YouTube Intent

The code above is in Java. You just need to make suitable changes to make it work in B4A. Check the B4A Intents documentation and may be some other threads on Intents here.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Youtube Videos in WebView

You can use the Youtube app to play the video, instead of Webview. That also won't open in full screen by default but at least the user knows all he needs to do is tilt the phone to landscape mode to get full screen.

You can open a video in the Youtube app using Intents

A Programmer's Ride: Android YouTube Intent

The code above is in Java. You just need to make suitable changes to make it work in B4A. Check the B4A Intents documentation and may be some other threads on Intents here.

I am working on a NookColor and it does not have YouTube App or any way to get it. I have to find a way to do it with b4a and webview.

Thanks,

Margret
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Youtube Video Link

Can you post the link you are using the play the video?

Here is one of the links I am trying to use. When I posted it, it changed to something else so I am putting it also as code:

B4X:
http://www.youtube.com/watch?v=zO2vfYNaIbk
YouTube - ‪Universe‬‏

Thanks,

Margret
 
Last edited:
Upvote 0

NJDude

Expert
Licensed User
Longtime User
But I don't think that works (at least on my phone), I see the picture but the WebView can't play the video, is that related to the "plugins" issue?

You can add:

B4X:
...src="http://www.youtube.com/embed/zO2vfYNaIbk[b]?autoplay=1[/b]"...

and still Flash doesn't work.
 
Last edited:
Upvote 0

Widget

Well-Known Member
Licensed User
Longtime User
Flush is not enabled by default due to a bug when you add the WebView with the designer. This is fixed for v1.6. You can either add it programmatically or use Reflector to enable it.

How is Flash enabled programmatically in v1.50?
Also can a YouTube video play in the Android Emulator using WebView in 1.5 or 1.6?

TIA
Widget
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
Erel,
Has there been any resolution to being able to stream YouTube videos in a WebView or in any other view?
When I load a Webview, the YouTube site comes up, I can see the video, but when I click Play, nothing happens.
The solution does not have to be a WebView.
Thanks,
Rusty
 
Upvote 0

Rusty

Well-Known Member
Licensed User
Longtime User
I have tried the example and no luck.
I have used the following code and I get an image of the YouTube video, but it will not play.
B4X:
Dim WebView1 As WebView
webview1.Initialize("")
webview1.loadurl("http://www.youtube.com/watch?v=Bxa0UV1lPTY") 
activity.AddView(webview1,0,0,100%x, 100%y)
any ideas?
Thanks
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
B4X:
Dim Intent1 As Intent
    Intent1.Initialize(Intent1.ACTION_VIEW, "http://m.youtube.com/watch?v=zLDIcIrZO8Y")
    Intent1.SetComponent("com.google.android.youtube/.WatchActivity")
 
    intent1.PutExtra("","http://m.youtube.com/watch?v=zLDIcIrZO8Y")
    StartActivity(Intent1)
 
Upvote 0

vb1992

Well-Known Member
Licensed User
Longtime User
Have you tried passing an Embedded Youtube into webview.loadhtml
not sure if it works, but it might

<iframe width="560" height="315" src="http://www.youtube.com/watch?v=p4wh0IksOfg" frameborder="0" allowfullscreen></iframe>
 
Upvote 0

netkomm

Active Member
Licensed User
Longtime User
Erel, it seems that your code is no longer working with the new version of Youtube.

Since there are still plenty of devices that cannot use the Youtube API... any idea of any possible fallback to show them the video?
 
Upvote 0

netkomm

Active Member
Licensed User
Longtime User
found the solution:

B4X:
Dim Intent1 As Intent
Intent1.Initialize(Intent1.ACTION_VIEW, "vnd.youtube:"&videoid)
Intent1.PutExtra("VIDEO_ID",videoid)
StartActivity(Intent1)

now... is there a way to force the orientation of an intent? (eg: landscape)?
 
Upvote 0
Top