[FREE]πŸ”Š MKMusicPLayer Extension with remarkable features

Hello Koders ! today Iam introducing MKMusicPlayer Extension

The MKMusicPlayer extension is a non-visible component that provides audio playback functionality for your MIT App Inventor project. You can play audio files from local storage or a URL, control playback (play, pause, resume, stop), set the playback speed, control volume, and set looping.

The extension requires READ_EXTERNAL_STORAGE and INTERNET permissions.


Blocks



component_event (3)

AudioLoaded event
The AudioLoaded event is triggered when the audio is loaded and prepared for playback. It has one parameter, success , which is a boolean value indicating whether the audio was successfully loaded (true) or not (false).




component_event (2)

AudioEnded event
The AudioEnded event is triggered when the audio playback has finished. It does not have any parameters and does not return any value.







component_event

FadeInCompleted
Description: Event triggered when the fade-in effect has completed.




component_event (1)

component_event

FadeOutCompleted
Description: Event triggered when the fade-out effect has completed.






component_event

AudioLoadError
Description: Event is triggered when the MKMusicPlayer fails to load an audio file. It provides an errorMessage detailing the reason for the failure, allowing you to handle the error in your app (e.g., display a message to the user).




component_method

LoadAudio

Description: Prepares an audio file from local storage or app assets for playback without automatically starting it. Handles different loading scenarios, errors, and triggers events to indicate loading success (AudioLoaded) or failure (AudioLoadError).

Parameters:

  • source (String): The path to the audio file (local storage) or filename (assets).


component_method(1)

LoadAudioFromURL

Description: Prepares an online audio file (specified by a URL) for playback without automatically starting it. Handles errors and triggers events to indicate loading success (AudioLoaded) or failure (AudioLoadError).

Parameters:

  • audioUrl (String): The URL of the audio file.


component_method (2)
PauseAudio`:

  • Pause the currently playing audio.




component_method (3)

ResumeAudio:

  • Start or Resume the paused audio.


component_method (4)

StopAudio

  • Stop and release the MediaPlayer instance.


component_method (5)

SetSeekPosition

  • (int position): Set the seek position of the audio file in milliseconds.


component_method (8)

SetVolumeLevel
(

  • int volumeLevel) Control the volume level of the audio in the range of 0 to 100.



component_method (7)

SetPlaybackSpeed

  • (float speed) Set the playback speed of the audio file. This function is supported on Android devices running API level 23 (Marshmallow) and above.
    this take float speed like these values (0.25 , 0.5 , 1 , 1.5 ,2 ,2.5 , 3 )


component_method (6)

SetLooping

  • (boolean looping)`: Enable or disable looping of the audio.




component_method

GetVolumeLevel

  • This function retrieves the current volume level of the audio being played by the media player. The volume level is represented as a value ranging from 0 to 100.


component_method (11)

GetDuration

  • Get the total duration of the audio file in milliseconds.


component_method (12)

HasAudioEnded

  • Check if the audio file has ended.



component_method (13)

GetCurrentPosition

  • Get the current seek position of the audio file in milliseconds.


component_method (10)

IsLooping

  • Check if the audio is set to loop.


component_method (9)

IsPlaying

  • Check if the audio is currently playing.



blocks (3)

FadeIn

  • Description: This function applies a fade-in effect to a media player, gradually increasing the volume from 0 to the final volume level over a specified duration.
    By using this function, you can achieve a fade-in effect by gradually increasing the volume of a mediaPlayer from 0 to a specified level over a given duration.

  • Parameters:

    • duration: An integer representing the fade-in duration in milliseconds.
    • finalVolume: An integer representing the desired volume level at the end of the fade-in.


blocks (2)

FadeOut

  • Description: This function applies a fade-out effect to a media player, gradually decreasing the volume from the initial volume level to 0 over a specified duration.
    By using this function, you can achieve a fade-out effect by gradually decreasing the volume of a mediaPlayer from the initial volume level to 0 over a given duration. The mediaPlayer will be paused after the fade-out is completed.

  • Parameters:

    • duration: The duration of the fade-out effect in milliseconds.
    • initialVolume: An integer representing the starting volume level.



component_event

RestartWithFadeIn

  • Description: Restarts the audio playback with a fade-in effect at the beginning.

  • Parameters:

    • duration: The duration of the fade-out effect in milliseconds.
    • initialVolume: An integer representing the starting volume level.

This MKMusicPlayer will solve these issues




Video


AIX file

You can download it from here :

V1
:arrow_down: MKMusicPlayer v1.aix (19.1 KB)



V2
:arrow_down: MKMusicPlayer v2.aix (19.3 KB)



V3
:arrow_down: MKMusicPlayer v3.aix (35.0 KB)




AIA file

You can download it from here :

MKplayer.aia (21.2 KB)


Β© Mr_koder. All rights reserved.

Thanks

Our Telegram Channel

Mr_Koder

Donate :

https://paypal.me/ahmed77383?country.x=EG&locale.x=en_US

10 Likes

Nice Extension

1 Like

@ayan1 thanks

new blocks with features added

2 Likes

Playback speed 1.2 - 1.75 … (Quarter) needs to be available too

it’s available just try it,
this extension has a range from 0.05 to 5 playback speed
However, I’m skeptical if it will have any significant impact.

How can I try it?

simply buy it and try it and if you have any problems you can contact me to solve it

The extension now is FREE

Enjoy

New Blocks Added and some bugs fixed

1 Like

Extension updated now you play audio files from assets , local paths and URLs

2 Likes

how to write the path that works oofline to play from asd and local ones?

Check V2 please I have updated the topic

1 Like

Now the extension works great >> thanks dear

1 Like

Hi, I tried to read my music files but I’m not getting any results…

I use

/storage/emulated/0/Music/

I use the follow code to read my music but it is not giving me any results please help me

The file path should be ended with audio extension like music1.mp3
The extension only read single audio file not bulk of audio files in stored in path

It takes very long time to play online mp3, exoplayer plays quickly my files but your extension takes too long to play!!! try to play multiple files one by one, play 1 then stop player then 2 & so on and then realize waiting time to load audio…it’s not useful!!

I will check it out and I will do some updates to fic the problems if is there are

And thanks for informing me about this .

Looks cool! The official audio player is pretty lacking, but this has so many features :open_mouth:

1 Like

Great Work :heart:

1 Like