B4A Library YouTubeToMP3

This library will allow you to extract the audio track from YouTube videos and save it as an MP3.

Requirements:

1- B4A 6.x.

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

3- Compile with SDK < 23, this is due to a glitch in the OkHTTP library which makes this lib not to work (This library uses the HTTP lib).

Usage:
B4X:
'Initialize the YouTubeToMP3 library.

Private YT As YouTubeToMP3

YT.Initialize(Activity, Me, "Tube")

YT.DownloadAndPlayMP3 = "sI7XiJgt0vY"

*** See the attached sample for more details.


NOTES:

- The "LazySearch" feature doesn't seem to work on versions older than 4.4.

- In very rare cases some MP3s cannot be played using the DownloadAndPlayMP3 method, but can be played using a media player.

- This library was part of a personal project, just sharing it in case someone has some use for it.


Screen shots:

Shot 1
Shot 2
 

Attachments

  • YouTubeToMP3_1.0_Lib.zip
    10.9 KB · Views: 251
  • YouTubeToMP3_Sample.zip
    11.7 KB · Views: 261
Last edited:

rscheel

Well-Known Member
Licensed User
Longtime User
Has a problem, the search does not work, just stays on the default, to advance the search page and return to work.
 

T201016

Active Member
Licensed User
Longtime User
Hi.
By testing some interesting YoutubeToMP3 library version 1.00
I encountered a surprising problem in my opinion.
By running the test on two separate system versions Android 4.3 and 5.1.1
The YT.LazySearch procedure in the example in both versions of Android worked differently:

B4X:
Sub SearchButton_Click

ProgressDialogShow ("Opening Search ...")

YT.LazySearch = "Technical Difficulties" 'https://www.google.com/search?q=Technical%20Difficulties&tbm=vid,

End Sub

1. at WiFi OFF - (file: Screenshot_2017-08-23-11-34-04)
2. at WiFi ON - (file: Screenshot_2017-08-23-11-35-57)

What I'm reading, in your recommendations, the YouTubeToMP3 v.1.00 library works conditionally at compilation
YouTubeToMP3_Sample (B4A Source Code) application - Version B4A 6.0 and works on devices
With version of Android higher than or equal to v4.4.

So why does not work with v.5.1.1? Is the problem only in using the lower version of B4A from recommended (B4A 6.x.)?

Thank you for any suggestions ...

PS. At compilation I use version B4A 5.20. SDK < 23.
 

Attachments

  • Screenshot_2017-08-23-11-35-57.png
    Screenshot_2017-08-23-11-35-57.png
    22.6 KB · Views: 150
  • Screenshot_2017-08-23-11-34-04.png
    Screenshot_2017-08-23-11-34-04.png
    151.7 KB · Views: 164
Last edited:

ilan

Expert
Licensed User
Longtime User
hi @NJDude i am trying your library but i am getting a crash:

SENTINEL_MSG_LIBCUTILS
SENTINEL_MSG_LIBLOG
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (mp3grabber) Create **
java.lang.NoSuchMethodError: No static method onStartCommand(Lanywheresoftware/b4a/BA;)Z in class Lanywheresoftware/b4a/objects/ServiceHelper$StarterHelper; or its super classes (declaration of 'anywheresoftware.b4a.objects.ServiceHelper$StarterHelper' appears in /data/app/njdude.youtubetomp3.sample-mstFkSHvc8QdStVpVSPAag==/base.apk)
at njdude.youtubetomp3.library.mp3grabber.onStartCommand(mp3grabber.java:68)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3677)
at android.app.ActivityThread.-wrap21(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1801)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
SENTINEL_MSG_LIBCUTILS
SENTINEL_MSG_LIBLOG

am i doing something wrong or is the lib no more working?

thanx, ilan
 
Top