MusicBoxCenter

Marc DANIEL

Well-Known Member
Licensed User
Here's the new version of "MusicBoxCenter" which will allow you to:
1- Create a folder for external storage
2- Upload 14 music files or videos to it
3- Record voice and audio using your smartphone's microphone and save them to external storage.

The application's internal music player recognizes and plays AAC, FLAC, MKV, MP3, MP4, and WAV files.

For files that are not supported (MID, MIDI) , you will be prompted to select your own applications (if any) to play them.



Download files >>> B4A files - APK file
 
Last edited:

Marc DANIEL

Well-Known Member
Licensed User
Please note that an antivirus or VPN installed on your device may block the download of music files and generate an error message or cause the application to crash.
 

Marc DANIEL

Well-Known Member
Licensed User
Disclaimer: I must humbly admit that I was unable to configure the dimensions and location of CLV1 (CustomListView) in the general "Music" Designer script because nothing matched my requirements. So, I just defined it in a simple way by adapting it to my own Smartphone.

Problem solved >>>
Designer Script:
'All variants script
'AutoScaleAll
W = 100%x
H = 100%y
Entete1.Left = 5
Entete1.Width = W - 10
Entete1.Height = H/17
Record.Top = Entete1.bottom + 10
Record.Left = 5
Record.Width = W - 10
Record.Height = H/22
FileList.Top = Record.bottom + 10
FileList.Left = 5
FileList.Width = W/2 - 15
FileList.Height = H/16
HideList.Top = Record.bottom + 10
HideList.Left = FileList.Right + 5
HideList.Width = W/2 - 15
HideList.Height = H/16
JukeBox.Top = FileList.Bottom + 10
JukeBox.Left = 5
JukeBox.Width = W - 20
JukeBox.Height = H/2.5
MusicTitle.Top = JukeBox.Bottom
MusicTitle.Left = 5
MusicTitle.Width = W-10
MusicTitle.Height = H/14
CLV1.Top = MusicTitle.Bottom + 20
CLV1.Height = H/2.8
CLV1.Bottom = H
CLV1.Width = W
CLV1.Left = 0
 
Last edited:

Marc DANIEL

Well-Known Member
Licensed User
Hello everyone. I've added a "Play Entire Playlist" feature to my app.

Only "accepted" music files will be played. A "MID" file won't cause an error but will block the player. In this case, simply move on to the next file on the player.

ExoPlayer.jpg


The download files have been updated. See the links above.​
 

Marc DANIEL

Well-Known Member
Licensed User
Private Sub PlayAllPlayList:
Private Sub PlayAllPlayList
    Msgbox2Async("Do you really want to listen to the entire recorded list?     Please note that if you have saved several dozen music files in the folder created for this application, you will have to wait a few seconds while the PlayList loads.", "Listen to the list", "Yes", "", "No", Null, True)
    Wait For Msgbox_Result (Result As Int)
    If Result=DialogResponse.POSITIVE Then
        Player1.Release
        Player1.Initialize("Player")
        Dim Sources As List
        Sources.Initialize
        For nf = 0 To ListSongName.Size -1
            SongName = ListSongName.Get(nf)
            Storage.FindFile(Storage.Root,SongName)
            If File.Exists(File.DirInternal, SongName) = False Then
                Dim iStream As InputStream, oStream As OutputStream
                Dim oFile As ExternalFile
                oFile = Storage.FindFileOrCreate(Storage.Root, SongName)
                If oFile.IsInitialized Then
                    iStream = Storage.OpenInputStream(oFile)
                    oStream = File.OpenOutput(File.DirInternal, SongName, False)
                    File.copy2(iStream, oStream)
                    iStream.Close
                    oStream.Close
                End If
            End If
            Sources.Add(Player1.CreateFileSource(File.DirInternal,SongName))
        Next
        Player1.Prepare(Player1.CreateListSource(Sources))
        JukeBox.Player = Player1
        Player1.Play
        MusicTitle.Text = "You are currently listening to the entire" & CRLF & "PLAYLIST saved in the folder you created !"
    End If
End Sub

Of course, the application will play all the music files that you may have manually added yourself to the folder you initially created. So these added files will be part of the PlayList
 
Last edited:

Marc DANIEL

Well-Known Member
Licensed User
travaux.gif
There were a few bugs in this application, including the inability to save "long" files. Thanks to Klaus's very valuable help, these bugs have been fixed. The download files have been updated.
 

Marc DANIEL

Well-Known Member
Licensed User
Last improvement thanks to the invaluable help of PaulMEURIS whom I thank again, you will no longer be asked to create an external data storage folder when starting the application IF you have already created this folder. The download files have been updated.

Sub Class_Globals:
Public PreviousUriFileName As String ="PersistantUri"

Please note, spell "PersistantUri" correctly and not "PersistantURI" for example.

Public Sub HasPermission As Boolean:
Public Sub HasPermission As Boolean
    If  File.Exists(File.DirInternal, PreviousUriFileName) Then
        PersistantURI = File.ReadString(File.DirInternal, PreviousUriFileName)
        Dim List As List = ctxt.RunMethodJO("getContentResolver", Null).RunMethod("getPersistedUriPermissions", Null)
        If List.IsInitialized Then     
            For Each uripermission As JavaObject In List
                Dim u As Uri = uripermission.RunMethod("getUri", Null)
                Dim temp As Object = u
                Dim s As String = temp
                If s = PersistantURI And uripermission.RunMethod("isWritePermission", Null) = True Then
                    Return True
                End If
            Next
        End If
    End If
    Return False
End Sub

Private Sub Depart
    If HasPermission Then
        FirstTime = False
        FileList_Click
    Else
        Msgbox2Async("You need to create a folder for sound recordings.", "Create new folder ?", "Yes", "", "No", Null, True)
        Wait For Msgbox_Result (Result As Int)
        If Result=DialogResponse.POSITIVE Then
            CreateNewDir
        Else
            FirstTime = False
            FileList_Click
        End If
    End If
End Sub
 
Last edited:

Marc DANIEL

Well-Known Member
Licensed User
Lines added to avoid a bug related to the cache not being empty when exiting the application


B4X:
Sub BtnSave_Click
    btnSave.Visible = False
    Msgbox2Async("Do you really want to save this sound?", "Save this sound", "Yes", "", "No", Null, True)
    Wait For Msgbox_Result (Result As Int)
    If Result=DialogResponse.POSITIVE Then
        FileName = RecordFileName
        CopyFileToExternalStorage(File.DirInternal, FileName, Storage.root, "")
        btnPlay.Visible=False
        btnSave.Visible = False
        Label1.Text = "Recording: " & FileName & " on your external storage"
        Sleep(2500)
        Label1.Text = "To find and listen to this recorded" & CRLF & "file, return to the MusicBoxCenter" & CRLF & "and display the file list."
        Sleep(2500)
        Label1.Text = ""
    End If
    If File.Exists(File.DirInternal, RecordFileName) = True Then
        MP.Release
        MP.Initialize
    End If
End Sub
 
Last edited:
Top