Cheerleader


Source link: https://github.com/tvbarthel/Cheerleader

Cheerleader is an Android open source library designed to easily support an artist in an Android application thanks to a SoundCloud account. This project is developed by two Android enthusiasts during their free times.

Cheerleader

The library is based on RxJava, if you aren't familiar with it, the following links are strongly recommended :

The library is composed of two main classes :

Summary

Why Cheerleader?

Find out our motivations.

Disclaimer

Cheerleader is a open-source library developped by two Android enthusiasts during their spare time. Cheerleader is provided "as it" and may present a few bugs on some smartphones. Please, feel free to show your support to this open-source project by leaving your feedback.

Don't forget to read the SoundCloud terms of use.

Please keep in mind that the main goal of this project is to help independent artists reach more fans and bring more visibility through an Android application. If you plans to monetize your app (please don't use Ads), check the Commercial Use section and be sure to pays the artist and SoundCloud for bringing diversified musics for free.

Gradle Dependency

Promoted on Maven Central :

compile 'fr.tvbarthel.cheerleader:library:1.0.2'

CheerleaderClient

As any client, the CheerleaderClient will provide a bridge between your app and the data stored on the SoundCloud servers.

Severals features have been implemented to avoid too many access to the SoundCloud API as well as trying to provide a better user experience :

  • Data will be cached in RAM as long as the client isn't closed (artist and tracks data are unlikely to change every minutes).
  • Response will be stored in a local database for offline usage (see "download track" feature in the TODO list for complete offline mode support).

Builder

  mCheerleaderClient = new CheerleaderClient.Builder()

 .from(context)

 .with(R.string.sound_cloud_client_id)

 .supports("artistToSupportName")

 .build();

Note that only one artist can be supported at the same time, any new attempt to build a new client for another artist will automatically close the old one.

##Features Currently, only few features are available. Have a look to the TODO section to check incomming features.

Artist's profile

Once a client has been build for a given artist, the complete SoundCloud profile can be retrieved (name, avatar url, description, followers count, etc.) :

  mCheerleaderClient.getArtistProfile()

 .subscribeOn(Schedulers.io())

 .observeOn(AndroidSchedulers.mainThread())

 .subscribe(new Action1<SoundCloudUser>() {

  @Override

  public void call(SoundCloudUser soundCloudUser) {

  
}

 
}
);

Artist's tracks

Public tracks of the supported artist are also available (title, artwork url, duration, wave form url, etc.) :

  mCheerleaderClient.getArtistTracks()

 .subscribeOn(Schedulers.io())

 .observeOn(AndroidSchedulers.mainThread())

 .subscribe(new Action1<ArrayList<SoundCloudTrack>>() {

  @Override

  public void call(ArrayList<SoundCloudTrack> soundCloudTracks) {

  
}

 
}
);

Comments

In addition, comments of a given track can be retrieved :

  mCheerleaderClient.getTrackComments(track)

 .subscribeOn(Schedulers.io())

 .observeOn(AndroidSchedulers.mainThread())

 .subscribe(new Action1<ArrayList<SoundCloudComment>>() {

  @Override

  public void call(ArrayList<SoundCloudComment> soundCloudComments) {

  
}

 
}
);

Debug

Designed to simplify the implementation of the library, we kept the possibility to display some logs in the LogCat :

  mCheerleaderClient = new CheerleaderClient.Builder()

 .from(context)

 .with(R.string.sound_cloud_client_id)

 .log(CheerleaderClient.LOG_OFFLINER)

 .supports("artistToSupportName")

 .build();

Note that a pipe can be used to chain log levels.

CheerleaderPlayer

The player encapsulate the whole playback logic including :

  • An internal playlist;
  • Phone Notification, small and expanded (Artist name, track title, track artwork, actions -play, pause, previous, next-);
  • Wear Notification (Artist name, track title, track artwork, actions -play, pause, previous, next, volume up, volume down-);
  • Lock screen enhancement while playing (track artwork);
  • Audio focus compliant (pause when headset is unplugged, pause/resume while hanging up the phone, etc.);
  • Support of third app equalizer.

Builder

  mCheerleaderPlayer = new CheerleaderPlayer.Builder()

 .from(this)

 .with(R.string.sound_cloud_client_id)

 .build();

Notification

By default, no pending intent is attached to the notification. In order to link your player activity just add the following lines to the Builder :

  mCheerleaderPlayer = new CheerleaderPlayer.Builder()

 .from(this)

 .notificationActivity(PlayerActivity.class)

 .notificationIcon(R.drawable.ic_notification)

 .notificationIconBackground(R.drawable.notification_ic_background)

 .with(R.string.sound_cloud_client_id)

 .build();

Note that small icon as well as small icon background (Lollipop+ only) can also be customized through the Builder.

Overview

Pre-Lollipop Post-Lollipop Nougat

Android Wear

Cheerleader now fully supports Android Wear ♥

Player Controls

Note: the color of the control background is extracted by Android from the artwork.

Player interface

The public interface of the Player should allow to perform all actions expected from a player.

mCheerleaderPlayer.addTrack(track, playNow);

 ...
 mCheerleaderPlayer.togglePlayback();

 ...
 mCheerleaderPlayer.previous();

 ...
 mCheerleaderPlayer.next();

 ...
 mCheerleaderPlayer.seekTo(milli);

 ...
 mCheerleaderPlayer.isPlaying();

 ...
 mCheerleaderPlayer.getCurrentTrack();

 ...
 

Check the java doc as well as the sample for more information on any variants of the methods above.

Player Listener

In order to provide meaningfull callback to the user, two diferent kinds of listener can be registered.

CheerleaderPlayerListener

Listener used to catch any events related to the playback including thoses from the notification / lockscreen controller.

  /** 
  * Called when a track starts to be played. 
  * 
  * @param track
 played track. 
  * @param position position of the played track in the playlist. 
  */
  void onPlayerPlay(SoundCloudTrack track, int position);

/** 
  * Called when a the player has been paused. 
  */
  void onPlayerPause();

/** 
  * Called when the player complete a seek action. 
  * 
  * @param milli time in milli of the seek. 
  */
  void onPlayerSeekTo(int milli);

/** 
  * Called when the player has been destroyed. 
  */
  void onPlayerDestroyed();

/** 
  * Called when the player paused due to buffering more data. 
  */
  void onBufferingStarted();

/** 
  * Called when the player resumed after having buffered enough data. 
  */
  void onBufferingEnded();

/** 
  * Called when current position time changed. 
  * 
  * @param milli current time in milli seconds. 
  */
  void onProgressChanged(int milli);

See also java mCheerleaderPlayer.registerPlayerListener(listener) and java mCheerleaderPlayer.unregisterPlayerListener(listener)

CheerleaderPlaylistListener

A second listener used to catch any events performed on the internal playlist.

 /** 
  * Called when a tracks has been added to the player playlist. 
  * 
  * @param track track added. 
  */
  void onTrackAdded(SoundCloudTrack track);

 /** 
  * Called when a tracks has been removed from the player playlist. 
  * 
  * @param track
track removed. 
  * @param isEmpty true if the playlist is empty after deletion. 
  */
  void onTrackRemoved(SoundCloudTrack track, boolean isEmpty);

See also java mCheerleaderPlayer.registerPlaylistListener(listener) and java mCheerleaderPlayer.unregisterPlaylistListener(listener)

Release Notes

  • 1.0.2:
    • Notification layout for Android N.
    • Use last build tools / libraries dependencies.
  • 1.0.1:
    • Allow multiple app using Cheerleader to be installed at the same time (x
    • add SoundCloudArtworkHelper#getCoverUrl(SoundCloudUser user, String size) method to retrieve user artwork url for different size.
  • 1.0.0:
    • No API break to mention.
    • Add the support of Android Wear notification.
    • Improve stability of the playback service.
    • Use last version of RxJava and Retrofit.

TODO

  • Add the possibility to download the tracks localy.
  • Support Android Auto.
  • Support Chromecast.

Methods Count

 |cheerleader 578
  |
 |client 264
  |
 |player 201
  |
 |offline 43
  |
 |media 29
  |
 |remote 22
  |
 |helpers 3

Contributing

Contributions are welcome (: You can contribute through GitHub by forking the repository and sending a pull request.

When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible. For this project, we tries to follow the code style guidelines of the Android open source project.

Don't forget to run gradlew :library:check to ensure static analysis tools won't break the build.

Credits

Credits go to Thomas Barthélémy https://github.com/tbarthel-fr and Vincent Barthélémy https://github.com/vbarthel-fr as well as The SoundCloud API Team for providing an API which allow the developers to build apps upon their services.

License

Copyright (C) 2015 tvbarthel

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Special Thanks to ...

Ivan B , for his daily support and motivation through his lyrics.

Resources

Provides a logging wrapper around a WebViewClient, in order to figure out what is going on.

This happens by creating a DebugWebViewClient which logs events and passes them to an enclosed WebViewClient.

An Android Parallax ViewPager.

The advantage of this library is that the UI components within the adapter view can be individually moved at different speeds.

Basic implementation of Android Recycler View purely written in Kotlin.

The ultimate developer guide to Android application linking methods.

Android library that makes it easy to create floating UI elements.

RIBs is the cross-platform architecture framework behind many mobile apps at Uber. The name RIBs is short of Router, Interactor and Builder, which are core components of this architecture. This framework is designed for mobile apps with a large number of engineers and nested states.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes