A shortcut wrap for this Github project ("....A simple audio player for Android that you can plugin to your apps quickly get audio playback working.....")
It plays MP3 songs from URLs that you add to a list within the B4A code
1. Download the B4A project
2. Download resource.zip, DemoRes.zip, and LibRes.zip. Extract the folders and copy them to be on the same folder level as that of the B4A projects /Objects and /Files folders
3. Also posting the Java code - change it to your liking
4. Posting the B4A library files - copy them to your additional library folder (the library actually combines the java code of 3 different Github postings)
5. Take note of the B4A manifest file (lessons learnt - the order/sequence of text in the B4A project's Manifest file matters).
6. You need an internet connection for this to work
7. Your need B4A 6+ for this to work with at least the Appcompat V3.20 and DesignSupport V2.00 enabled in the libs tab of the B4A project
Sample Code:
It plays MP3 songs from URLs that you add to a list within the B4A code
1. Download the B4A project
2. Download resource.zip, DemoRes.zip, and LibRes.zip. Extract the folders and copy them to be on the same folder level as that of the B4A projects /Objects and /Files folders
3. Also posting the Java code - change it to your liking
4. Posting the B4A library files - copy them to your additional library folder (the library actually combines the java code of 3 different Github postings)
5. Take note of the B4A manifest file (lessons learnt - the order/sequence of text in the B4A project's Manifest file matters).
6. You need an internet connection for this to work
7. Your need B4A 6+ for this to work with at least the Appcompat V3.20 and DesignSupport V2.00 enabled in the libs tab of the B4A project
B4X:
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="22"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
AddApplicationText(<service
android:name="com.example.jean.jcplayer.JcPlayerService" />
<receiver
android:name="com.example.jean.jcplayer.JcPlayerNotificationReceiver"
android:enabled="true"
android:exported="false" />
<activity android:name="com.example.jean.jcplayersample.MainActivity">
</activity>)
Sample Code:
B4X:
#Region Project Attributes
#ApplicationLabel: b4aJcPlayer
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: False
#End Region
#AdditionalRes: ..\resource
#AdditionalRes: ..\DemoRes
#AdditionalRes: ..\LibRes
'#AdditionalRes: C:\Users\----------2\Documents\Basic 4 Android\JOHAN APPS\JHS LIBS\resource\b4a_appcompat, de.amberhome.objects.appcompat
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\Android\extras\google\google-play-services\libproject\google-play-services_lib\res, com.google.android.gms
'#AdditionalRes: C:\ANDRIOD_SDK_TOOLS\extras\android\support\design\res, android.support.design
'#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
'#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama
'#Extends: android.support.v7.app.AppCompatActivity
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Button1 As Button
Dim jcp As JcPlayer
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Dim musiclist As List
musiclist.Initialize
musiclist.Add("http://www.villopim.com.br/android/Music_01.mp3")
musiclist.Add("http://www.villopim.com.br/android/Music_02.mp3")
jcp.URLs = musiclist
Activity.LoadLayout("main")
jcp.Initialize("")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Button1_Click
jcp.startJcPlayer
End Sub