MusicBar 2.1 0.0 Java view visualize progress bar for sound file like sound cloud

Related tags

ProgressBar MusicBar
Overview

MusicBar Logo

MusicBar Download Android Arsenal

Setup

dependencies {
      implementation 'com.oze.music:MusicBar:1.0.5'
}

Usage

Function Description
setAnimationChangeListener(OnMusicBarAnimationChangeListener listener) animation listener
setProgressChangeListener(OnMusicBarProgressChangeListener listener) progress listener
removeAllListener() remove Progress and Animation listener
loadFrom(InputStream stream, int duration) take the music file InputStream with music duration in millisecond
loadFrom(String pathname, int duration) take the music file path with music duration in millisecond
show() start show animation
hide() start hide animation
startAutoProgress(float playbackSpeed) start auto play animation should be called after loadFrom() and media player finished prepare if startAutoProgress() called before loadFrom() it will throw exception because duration is 0. every time loadFrom() call you will need to recall startAutoProgress() playbackSpeed playback speed from media player default value 1.0F for MediaPlayer and ExoPlayer
stopAutoProgress() stop auto progress animation
isHide() return true if hide
isShow() return true if show
isAutoProgress() return true if auto progress
setProgress(int position) move to specified position (in milisecand)
getPosition() return current progress position
setSpaceBetweenBar(int spaceBetweenBar) change distance between bars (in px) default 2 Recommend to make spaceBetweenBar equal barWidth if you use FixedMusicBar
setBarWidth(float barWidth) change bar width (in px) default 2 for FixedMusicBar and 3 for ScrollableMusicBar Recommend to make barWidth equal spaceBetweenBar if you use FixedMusicBar
setLoadedBarPrimeColor(int color) change top progressed bar color default #fb4c01
setBackgroundBarPrimeColor(int color) change top unprogressed bar color default #dfd6d6

Only in ScrollableMusicBar

Function Description
setDivided(boolean divided) Set if music bar divided or not default false
setDividerSize(float size) Set divider size in px default 2 use when view is divided
setLoadedBarSecondaryColor(int color) change bottom progressed bar color default #eca277 use when view is divided
setBackgroundBarSecondaryColor(int color) change bottom unprogressed bar color default #c4bbbb use when view is divided

XML

for ScrollableMusicBar

ScrollableMusicBar

   <com.oze.music.musicbar.ScrollableMusicBar
        android:id="@+id/ScrollableMusicBar"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:background="@android:color/white"
        android:padding="8dp"
        app:divided="true"                               // to divide each bar default false
        app:dividerSize="2"                              // divide sice in px default 2
        app:barWidth="3"                                 // bar width default 3
        app:spaceBetweenBar="2"                          // distance between each bar default 2
        app:backgroundBarPrimeColor="#dfd6d6"
        app:backgroundBarSecondaryColor="#c4bbbb"
        app:LoadedBarPrimeColor="#fb4c01"
        app:LoadedBarSecondaryColor="#eca277"/>

OR FixedMusicBar

FixedMusicBar

    <com.oze.music.musicbar.FixedMusicBar
        android:id="@+id/FixedMusicBar"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:padding="8dp"
        android:background="@android:color/white"
        app:barWidth="2"                           // bar width default 2
        app:spaceBetweenBar="2"                    // distance between each bar default 2
        app:backgroundBarPrimeColor="#dfd6d6"
        app:LoadedBarPrimeColor="#fb4c01"/>

Java

 @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        ScrollableMusicBar musicBar = findViewById(R.id.ScrollableMusicBar);
        //or  
        FixedMusicBar musicBar = findViewById(R.id.FixedMusicBar);
        
        //add animation listener
        musicBar.setAnimationChangeListener(mOnMusicBarAnimationChangeListener);
        
        //add progress listener
        musicBar.setProgressChangeListener(mOnMusicBarProgressChangeListener);
        
         // String path = the music file path
        // int duration = the music file duration time in millisecond [mediaPlayer.getDuration()]
        musicBar.loadFrom(path,duration)
        //or use inputstream 
        musicBar.loadFrom(getResources().openRawResource(R.raw.music),duration());
        
        //change progress 
        musicBar.setProgress(50)
        
        //start show animation
        musicBar.show()
        
        //start hide animation
        musicBar.hide()
        
        //change bar width
        musicBar.setBarWidth(2);
        
        //change Space Between Bars
        musicBar.setSpaceBetweenBar(2); //Recommend to make spaceBetweenBar equal barWidth if you use FixedMusicBar
       
        // Set if music bar divided or not default value false.
        musicBar.setDivided(true);
        
        //Set divider size in px default value 2
        musicBar.setDividerSize();
        
        // for changing color scheme
        musicBar.setBackgroundBarPrimeColor(getResources().getColor(R.color.BackgroundBarPrimeColor);
        musicBar.setBackgroundBarSecondaryColor(getResources().getColor(R.color.BackgroundBarSecondaryColor);
        musicBar.setLoadedBarPrimeColor(getResources().getColor(R.color.LoadedBarPrimeColor);
        musicBar.setLoadedBarSecondaryColor(getResources().getColor(R.color.LoadedBarSecondaryColor);


        mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mp) {
                musicBar.startAutoProgress(1.0f);
            }
        });
        
        //stop auto progress animation
        musicBar.stopAutoProgress();
        
    }

AnimationListener

MusicBar.OnMusicBarAnimationChangeListener mOnMusicBarAnimationChangeListener = new MusicBar.OnMusicBarAnimationChangeListener() {
        @Override
        public void onHideAnimationStart() {
            Log.i(TAG, "onHideAnimationStart");
        }

        @Override
        public void onHideAnimationEnd() {
            Log.i(TAG, "onHideAnimationEnd");
        }

        @Override
        public void onShowAnimationStart() {
            Log.i(TAG, "onShowAnimationStart");

        }

        @Override
        public void onShowAnimationEnd() {
            Log.i(TAG, "onShowAnimationEnd");
        }
    };

ProgressListener

 MusicBar.OnMusicBarProgressChangeListener mOnMusicBarProgressChangeListener = new MusicBar.OnMusicBarProgressChangeListener() {
        @Override
        public void onProgressChanged(MusicBar musicBar, int progress, boolean fromUser) {
            Log.i(TAG, "onProgressChanged");
        }

        @Override
        public void onStartTrackingTouch(MusicBar musicBar) {
         Log.i(TAG, "onStartTrackingTouch");
        }

        @Override
        public void onStopTrackingTouch(MusicBar musicBar) {
            Log.i(TAG, "onStopTrackingTouch");
        }
    };

Animation

animation

You might also like...
A customizable, animated progress bar that features rounded corners. This Android library is designed to look great and be simple to use πŸŽ‰
A customizable, animated progress bar that features rounded corners. This Android library is designed to look great and be simple to use πŸŽ‰

RoundedProgressBar Easy, Beautiful, Customizeable The RoundedProgressBar library gives you a wide range of customizable options for making progress ba

[Android] Round Corner Progress Bar Library for Android
[Android] Round Corner Progress Bar Library for Android

RoundCornerProgressBar Round corner is cool. Let's make your progress bar to round corner Colorful progress bar with round corner on progress which yo

DownloadProgressBar is an android library that delivers awesome custom progress bar. You can manipulate it's state in every way.
DownloadProgressBar is an android library that delivers awesome custom progress bar. You can manipulate it's state in every way.

Download Progress Bar Android progress bar with cool animation, inspired by : https://dribbble.com/shots/2012292-Download-Animation ###Attributes Attr

Android - An action bar item which acts both as a refresh button and as a progress indicator
Android - An action bar item which acts both as a refresh button and as a progress indicator

RefreshActionItem An action bar item that implements this common pattern: Initially it shows a refresh button. If the button is clicked, a background

A customizable indeterminate progress bar
A customizable indeterminate progress bar

DilatingDotsProgressBar Installation compile 'com.github.justzak:dilatingdotsprogressbar:1.0.1' Usage com.zl.reik.dilatingdotsprogressbar.DilatingDo

Open source android library for different progress bar designs
Open source android library for different progress bar designs

MultiProgressBar A progress bar library for Android that provides customized progress bars. Built with ❀︎ by Aseem Khare πŸ’» Installation Add this in y

Arc pointer - simple customized progress bar in the form of an arch
Arc pointer - simple customized progress bar in the form of an arch

ArcPointer Simple customized progress bar in the form of an arch Demo Quick start Step 1 Gradle: compile 'io.github.dvegasa:arcpointer:1.0.2' Maven:

Progress Bar in the shape of regular polygon.
Progress Bar in the shape of regular polygon.

N-SidedProgressBar Progress Bar in the shape of regular polygon. Download The library is available on jcenter. Just add the dependency to your build.g

a circle progress bar with effect
a circle progress bar with effect

RingProgress a circle progress bar with effect #Preview ##Usage xml com.ldoublem.ringPregressLibrary.RingProgress android:id="@+id/ring_prog

Comments
  • MusicBar constantly logging progress

    MusicBar constantly logging progress

    Hello,

    I will implement Your library, which is super cool, in the new version of my app.

    Anyway, I noticed that the library constantly logs progress.

    screen_as

    I'm pretty sure logging has an impact on performance. I'm aware of the importance of logging, but in my opinion You should remove it from the release builds of the library.

    I'm going to release the app regardless of this small issue.

    Thanks for Your hard work! :)

    opened by enricocid 0
  • Progress Animation

    Progress Animation

    Hi, Nice work! πŸ‘ But.. I Imagine, the idea is to make this music bar as close as possible to the music bar that Soundcloud uses, right? So, the animation for progress is not correct, since the animation should be continuous and not advance each bar. A possible solution for animation is to use Long and not Integer for the times since with Exoplayer2 Long is required for times.

    Also, the scroll need to be more flexible, like a normal ScrollView.

    Anyway, Good work! Cheers!

    opened by Andreu35 0
  • getting error

    getting error " divide by zero"

    I was opening an activity that have a MusicBar View, and it just crash everytime i tried to open it

    java.lang.ArithmeticException: divide by zero at com.oze.music.musicbar.MusicBar.getBarHeight(MusicBar.java:218) at com.oze.music.musicbar.FixedMusicBar.onDraw(FixedMusicBar.java:37) at android.view.View.draw(View.java:19261) at android.view.View.updateDisplayListIfDirty(View.java:18211) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.updateDisplayListIfDirty(View.java:18202) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.draw(View.java:19264) at android.view.View.updateDisplayListIfDirty(View.java:18211) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.updateDisplayListIfDirty(View.java:18202) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.draw(View.java:19264) at android.view.View.updateDisplayListIfDirty(View.java:18211) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.draw(View.java:19264) at android.view.View.updateDisplayListIfDirty(View.java:18211) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.updateDisplayListIfDirty(View.java:18202) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at androidx.recyclerview.widget.RecyclerView.drawChild(RecyclerView.java:5030) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.draw(View.java:19264) at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4429) at android.view.View.updateDisplayListIfDirty(View.java:18211) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.draw(View.java:19264) at android.view.View.updateDisplayListIfDirty(View.java:18211) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.updateDisplayListIfDirty(View.java:18202) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.updateDisplayListIfDirty(View.java:18202) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at androidx.coordinatorlayout.widget.CoordinatorLayout.drawChild(CoordinatorLayout.java:1246) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.draw(View.java:19264) at android.view.View.updateDisplayListIfDirty(View.java:18211) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.updateDisplayListIfDirty(View.java:18202) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096) at android.view.View.updateDisplayListIfDirty(View.java:18202) at android.view.View.draw(View.java:18989) at android.view.ViewGroup.drawChild(ViewGroup.java:4310) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4096)

    opened by LuilliCapellan 0
Owner
emad
emad
A progress wheel for android, intended for use instead of the standard progress bar.

Deprecation warning This project is no-longer maintained, and has not been maintained for a few years now. If you're looking for an alternative librar

Todd Davies 2.7k Dec 29, 2022
:barber: [Android Library] Stacked dual progress indicator progress-bar

StackedHorizontalProgressBar Specs Featured in Show some ❀️ Android library with ability to show two progress indicators in one horizontal progress ba

Nishant Srivastava 98 Nov 11, 2022
An instagram-like segmented progress bar

An instagram-like segmented progress bar

Tiago Ornelas 286 Jan 6, 2023
Android loading or progress dialog widget library, provide efficient way to implement iOS like loading dialog and progress wheel

ACProgressLite English Version / δΈ­ζ–‡η‰ˆζœ¬ An Android loading widget library. Lite and easy to use, strong customizability. Can be used to implement 'iOS'

Cloudist Technology Co., Ltd. 234 Nov 24, 2022
A wave view of android,can be used as progress bar.

WaveView ![Gitter](https://badges.gitter.im/Join Chat.svg) A wave view of android,can be used as progress bar. Screenshot APK demo.apk What can be use

Kai Wang 1.3k Dec 28, 2022
A simple lib to create a ring-like progress view with corner edges

ProgressRingView Installation Gradle: dependencies { compile 'com.github.flepsik:progress-ring-view:1.2.1' } Maven: <dependency> <groupId>com.g

null 71 Dec 5, 2021
Simple Progress View that you can compare things, like statistics of a Football match

Simple Progress View that you can compare things, like statistics of a Football match

Kostas Antoniou 29 Jun 8, 2022
ColoringLoading 4.7 0.0 Java This project provide Coloring Loading View for Android. And this project is not using the image file!

ColoringLoading ![Release](https://img.shields.io/github/release/recruit-lifestyle/ColoringLoading.svg?label=maven version) This project provide Color

Recruit Lifestyle Co. Ltd. 379 Jul 25, 2022
[Android] Round Corner Progress Bar Library for Android

RoundCornerProgressBar Round corner is cool. Let's make your progress bar to round corner Colorful progress bar with round corner on progress which yo

Akexorcist 2.3k Dec 31, 2022
This is beautiful color arc progress bar.

ColorArcProgressBar δΈ­ζ–‡η‰ˆ This is a customizable circular progressbar.It can achieve the effect of the QQ health's arc progress with XML. What's more, w

PASSION 928 Dec 6, 2022