B4A Library CustomYouTubeFeed

This library will allow you to get YouTube Feeds and display them on a WebView.

Requirements:

- B4A 2.7x


How to install:

- Copy the CustomYouTubeFeed.jar and CustomYouTubeFeed.xml to your additional libraries directory.


How to use:

B4X:
'Initialize the library
Dim Feed As CustomYouTubeFeed

Feed.Initialize(WebView1, "", "")

'Select the feed you want to retrieve, for example: Get user uploads
Feed.GetUserUploads("basic4android", 1, 25)

That's it!!.

You can use the WebView's events to do further processing of the results if needed.


This library will allow you to:

* Search Videos
* Browse Category
* Get User Uploads
* Get Channels
* Get Most Viewed Channels
* Get Most Subscribed Channels
* Get Most Popular
* Get Most Popular By Category
* Get Playlists
* Get Related Videos

There are also two variables:

- FeedType: Returns the selected feed.
- Results: Returns the number of results found.

The attached sample shows how simple is to use this library.

NOTE: Google has removed this API, this library no longer works.
 

Attachments

  • CustomYouTubeFeed_Library_1.0.zip
    8.7 KB · Views: 389
  • YouTubeFeed_Sample.zip
    11.3 KB · Views: 394
Last edited:

tuhatinhvn

Active Member
Licensed User
Longtime User
Parsing code. 0.00
Compiling code. 0.04
Compiling layouts code. 0.00
Generating R file. 0.27
Compiling generated Java code. 0.96
Convert byte code - optimized dex. Error
A referenced library is missing: net
 

dziner

New Member
Licensed User
Longtime User
Hi,
I tried your sample feed program. It shows a list of videos, but when I try to play a youtube video, it just doesn't play.
I've included Net lib, and I'm using B4a V. 3.00.
Any idea?
 

JOTHA

Well-Known Member
Licensed User
Longtime User
@NJDude, thank you for your answer.

I was searching for a video:
Feed.SearchVideos("SUGARHILL GANG - RAPPERS DELIGHT, KARAOKE, LYRICS", fIndex, fMaxResults)
The app found it. I clicked on the title in the list and the title apeared.

When I tapped on the play button a circle (wait ...) apears long time, but it doesn't play the video.
 

JOTHA

Well-Known Member
Licensed User
Longtime User
I tried the YouTube app from google play => it works.

I installed again your app => it doesn't play the video. sorry ...

Please see attached files:
1) ... found title, clicked PLAY button
2) ... WAIT Circle ... thats all.

Screenshot_2014-03-26-20-38-36.png
Screenshot_2014-03-26-20-38-45.png
 

JOTHA

Well-Known Member
Licensed User
Longtime User
Sounds good ... but how to?
... but isn't it better to use the youTube app directly instead?

The goal was to use it inside another app ...
 

NJDude

Expert
Licensed User
Longtime User
The problem you are having might be related to the browser on your device (flash player) but, if you want, you can use the YouTube app, use this code:
B4X:
Sub WebView1_OverrideUrl(Url As String) As Boolean

    Dim PlayVideo As Intent
    Url = Url.Replace("http://www.youtube.com/watch?v=", "").Replace("&feature=youtube_gdata", "")

    PlayVideo.Initialize(PlayVideo.ACTION_VIEW, "vnd.youtube:" & Url)
    PlayVideo.PutExtra("force_fullscreen", True) '<-- Full screen
				
    StartActivity(PlayVideo)
    
    ToastMessageShow(Feed.FeedType, False)				
	   
    Return True				
	
End Sub
 

JOTHA

Well-Known Member
Licensed User
Longtime User
Thank you NJDude, with this code it works! :D
 

Douglas Farias

Expert
Licensed User
Longtime User
why not appear to me the menu to browse youtube videos, etc.?
 

Douglas Farias

Expert
Licensed User
Longtime User
this menu in red dont show for me
i m compiled your exemple and i dont make changes.
i tested in my real device and dont show this youtube menu
 

Attachments

  • Screenshot_2014-03-26-20-38-36.png
    Screenshot_2014-03-26-20-38-36.png
    139.5 KB · Views: 174

MarcoRome

Expert
Licensed User
Longtime User
Hi NJDude :)

I working PlayList...


B4X:
....
Feed.GetPlaylists("music", fIndex, fMaxResults) '<--- Work
.....
 
Sub WebView1_PageFinished(Url As String)
Dim PlayVideo As Intent
    'Url = Url.Replace("http://www.youtube.com/watch?v=", "").Replace("&feature=youtube_gdata", "")
    Url = Url.Replace("http://www.youtube.com/watch?v=", "").Replace("&List=youtube_gdata", "")

    PlayVideo.Initialize(PlayVideo.ACTION_VIEW, "vnd.youtube:" & Url)
    'PlayVideo.PutExtra("force_fullscreen", True) '<-- Full screen

               
    StartActivity(PlayVideo)
....

PlayList is ok ... but i think that i wrong in WebView1 ...Replace("&List=youtube_gdata", "") because so dont work
Any idea ?
Thank'sss
 

NJDude

Expert
Licensed User
Longtime User
That's not correct, if you are getting a PlayList you have to open the list, like this:
B4X:
Sub WebView1_PageFinished(Url As String)
    
    Dim i As Intent

    i.Initialize(i.ACTION_VIEW, Url)

    StartActivity(i)

End Sub
 
Top