• Stars
    star
    881
  • Rank 51,820 (Top 2 %)
  • Language
    Java
  • License
    MIT License
  • Created over 8 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Awesome Audio Widget for any Android Music App

Audio Widget Overlay View Awesome

Header image

Meet the Audio Widget Overlay View by Cleveroad

You know, guys, we have become a bit obsessed with music recently. See yourself by checking our previous work on the Audio Visualization View library. Since we wanted to create a companion to our equalizer and add to the collection of Android widgets, the idea to develop a nice and convenient audio widget was born almost immediately. So if you have already developed a music player and you feel that you want to make it even better, then you’re welcome to use our library and enjoy the results.

Demo image

Also you can watch the animation of the Audio Widget Overlay on YouTube in HD quality.

Our invention can facilitate the user’s interaction with a music player and nicely decorate his device screen. Moreover, it’s really easy to integrate! Read our Case Study: Audio Widget Overlay View by Cleveroad to ensure that and find more of useful information.

Article image

Awesome

Setup and usage

To use Audio Widget Overlay first add dependency to your project:

dependencies {
    implementation 'com.cleveroad:audiowidget:1.0.2'
}

This library will add two new permissions to your manifest:

<!-- used for drawing widget. This permission must be granted before calling AudioWidget.show(). -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>

<!-- used for notifing user that he is about to remove widget when he drags it on remove widget icon. -->
<!-- This permission granted by default on Android 6.0+ devices. -->
<uses-permission android:name="android.permission.VIBRATE"/>

Then you can create new instance of widget using builder:

AudioWidget audioWidget = new AudioWidget.Builder(context)
        .lightColor(...)
        .darkColor(...)
        .expandWidgetColor(...)
        .progressColor(...)
        .progressStrokeWidth(...)
        .crossColor(...)
        .crossOverlappedColor(...)
        .crossStrokeWidth(...)
        .buttonPadding(...)
        .bubblesMinSize(...)
        .bubblesMaxSize(...)
        .shadowColor(...)
        .shadowRadius(...)
        .shadowDx(...)
        .shadowDy(...)
        .playDrawable(...)
        .pauseDrawable(...)
        .playlistDrawable(...)
        .prevTrackDrawale(...)
        .nextTrackDrawable(...)
        .defaultAlbumDrawable(...)
        .edgeOffsetXCollapsed(...)
        .edgeOffsetYCollapsed(...)
        .edgeOffsetXExpanded(...)
        .edgeOffsetYExpanded(...)
        .build();

Or you can use default configuration. Just call:

AudioWidget audioWidget = new AudioWidget.Builder(context).build();

Then you can use audio widget's controller to listen for events:

// media buttons' click listener
audioWidget.controller().onControlsClickListener(new AudioWidget.OnControlsClickListener() {
    @Override
    public boolean onPlaylistClicked() {
        // playlist icon clicked
        // return false to collapse widget, true to stay in expanded state
    }

    @Override
    public void onPreviousClicked() {
        // previous track button clicked
    }

    @Override
    public boolean onPlayPauseClicked() {
        // return true to change playback state of widget and play button click animation (in collapsed state)
        return true;
    }

    @Override
    public void onNextClicked() {
        // next track button clicked
    }

    @Override
    public void onAlbumClicked() {
        // album cover clicked
    }
    
    @Override
    public void onPlaylistLongClicked() {
        // playlist button long clicked
    }
    
    @Override
    public void onPreviousLongClicked() {
        // previous track button long clicked
    }
    
    @Override
    public void onPlayPauseLongClicked() {
        // play/pause button long clicked
    }
    
    @Override
    public void onNextLongClicked() {
        // next track button long clicked
    }

    @Override
    public void onAlbumClicked() {
        // album cover long clicked
    }

    @Override
    public void onAlbumLongClicked() {
        // album cover long clicked
    }
});

// widget's state listener
audioWidget.controller().onWidgetStateChangedListener(new AudioWidget.OnWidgetStateChangedListener() {
    @Override
    public void onWidgetStateChanged(@NonNull AudioWidget.State state) {
        // widget state changed (COLLAPSED, EXPANDED, REMOVED)
    }

    @Override
    public void onWidgetPositionChanged(int cx, int cy) {
        // widget position change. Save coordinates here to reuse them next time AudioWidget.show(int, int) called.
    }
});

Using AudioWidget.Controller, you can set track's duration, current position or album cover. Also you can set current playback state using start(), pause() or stop() methods. See MusicService class for more info on how to use controller.

To show audio widget on screen call AudioWidget.show(int, int) method. To hide it call AudioWidget.hide() method. Very simple!

audioWidget.show(100, 100); // coordinates in pixels on screen from top left corner
...
audioWidget.hide();

But make sure that your app has permission to draw over another apps in Android 6.0+. You can do it like this (in Activity):

    ...
    
    // somewhere in your code
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(this)) {
        Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + getPackageName()));
        startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
    }
    
    ...
    
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && Settings.canDrawOverlays(this)) {
                // now you can show audio widget
            }
        }
    }
    
    ...

Migration from v.0.9.1 to v.0.9.2

  • OnControlsClickListener.onPlaylistClicked should return true to consume the action or false to use default behavior (collapse the widget)
  • OnControlsClickListener.onPlayPauseClicked should return true to consume the action or false to use default behavior (change play/pause state)

Changelog

See changelog history.


#### Support #### * * * If you have any other questions regarding the use of this library, please contact us for support at [email protected] (email subject: "Audio Widget Overlay View. Support request.")
#### License #### * * * The MIT License (MIT)
Copyright (c) 2016 Cleveroad Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

More Repositories

1

SlidingTutorial-Android

Android Library for making animated tutorials inside your app
Java
2,486
star
2

FanLayoutManager

Using Fan Layout Manager you can implement the horizontal list, the items of which move like fan blades
Java
2,056
star
3

AdaptiveTableLayout

Library that makes it possible to read, edit and write CSV files
Java
1,902
star
4

WaveInApp

Live Audio Equalizer with wave effect
Java
1,785
star
5

LoopBar

Tap Bar with infinite scrolling. Make the navigation menu right at fingerprints, in a tab bar.
Java
741
star
6

CRNetworkButton

Send Button for iOS
Swift
654
star
7

FireworkyPullToRefresh

Let's try to refresh your data with our library!
Java
641
star
8

BubbleAnimationLayout

You don’t want your apps look and feel boring, do you? Add some bubbles!
Java
577
star
9

CycleMenu

Custom LayoutManager for the inner RecyclerView
Java
575
star
10

CRPageViewController

While a standard page view allows you to navigate between pages by using simple gestures, our component goes further
Objective-C
394
star
11

PlayWidget

Break the monotony and make your music player unique!
Java
366
star
12

Bitutorial

Crumbling tutorial for Android Apps
Java
357
star
13

CRParticleEffect

A CocoaPod that simplifies creation of the particle effects.
Objective-C
348
star
14

Android-Marshmallow-Boot-Animation

Java
244
star
15

DroidArt

Android library that allows perform manipulations with text and easily combine it with images.
Kotlin
209
star
16

BlurTutorial

Library for creating blur effects under Android UI elements
Kotlin
155
star
17

flutter_sliding_tutorial

User onboarding library with smooth animation of objects and background colors
Dart
127
star
18

CRRulerControl

Customizable component, created by Cleveroad iOS developers, is aimed at turning a simple ruler into a handy and smart instrument
Objective-C
112
star
19

ARFaceDetection

AR-based library for Android which is capable of detecting faces and overlaying images above the user’s head
Kotlin
52
star
20

slidingtutorial-ios

iOS Library for making animated tutorials inside your app
Objective-C
49
star
21

Bootstrap

This set of libraries is designed to help developers accomplish various tasks easier and faster
Kotlin
40
star
22

cr_calendar

Highly customizable, feature-packed calendar widget for Flutter.
Dart
31
star
23

CRRollingLabel

Objective-C
30
star
24

CRCellCollectionView

With this component, pictures in your apps collection view will look like honeycomb instead of the boring standard variant
Objective-C
28
star
25

ColorDetection

ColorDetection is an app built with OpenCV and using computer vision at its core. It’s able to detect and change colors of objects using a camera of iOS devices.
Objective-C++
22
star
26

cr_logger

Dart
15
star
27

cr_file_saver

Kotlin
3
star
28

CRRefreshControl

2
star
29

cr_json_widget

Dart
2
star
30

CRPlotView

1
star
31

CRPinCodeControl

1
star
32

cr_mentions

Dart
1
star