sc-PlayerButton


Source link: https://github.com/Paroca72/sc-player

sc-PlayerButton

Create a simple button than play a media source.
The basic function are simple a Play/Stop on pressing the button. The button will show the wave-form on playing the media.

IMPORTANT
For showing the wave form require the RECORD_AUDIO permission.
If not, will show a PLAY/STOP simple icon and NOT will show the wave form.


This class inherit from the android View class.
So for example if you would change the background is enough to use the android:background property. For customize the component please read guide below.

Public methods

  • int getDuration()
    Get back the media duration.

  • boolean isPlaying()
    Get the media playing status.

  • void play()
    Start to play the current media

  • void stop()
    Stop to play the current media

  • void setOnEventListener(OnEventListener listener)
    Set the event listener.


Getter and Setter

  • get/setSource -> String value, default null
    Set the current media source (absolute path).

  • get/setColor -> Color value, default #FFFFFF
    Set the current foreground color.

  • get/setFontSize -> float value, default 11dp
    Set the current font size.

  • get/setVolume -> float value, default 0.7
    Set the current media player volume (0..1).

  • get/setPosition -> int value, default 0
    Set the current media player position.


Interfaces

  • OnEventListener
    void onStartPlay(MediaPlayer player);
    Called when the media start to play.
    void onStopPlay();
    Called when the media stop to play.


XML Properties

<declare-styleable name="ScPlayerButton">
  <attr name="source" format="string" />
  <attr name="color" format="color" />
  <attr name="fontSize" format="dimension" />
  <attr name="volume" format="float" /> </declare-styleable>

Usage

via Gradle:
Add it in your root build.gradle at the end of repositories:

allprojects {
  repositories {

...
maven {
 url "https://jitpack.io" 
}
  
}
 
}

Add the dependency

dependencies {

  ...
  compile 'com.github.paroca72:sc-player:1.0.2' 
}

Coding

// Get the components ScPlayerButton player = (ScPlayerButton) this.findViewById(R.id.player);
 assert player != null;  // Play the default ringtone Uri defaultRintoneUri = RingtoneManager

.getActualDefaultRingtoneUri(this.getApplicationContext(), RingtoneManager.TYPE_RINGTONE);
 player.setSource(defaultRintoneUri.toString());


License

 Copyright 2015 Samuele Carassai
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. 

Resources

A sample Android application to demonstrate how to build screens as fully independent modules.

It relies on a Finite State Machine (EasyFlow), to handle screens as states and trigger/consume events. Events allow the application to handle navigation between screens. The global context of the FSM is used to pass arguments as a Bundle. It also shows how to use dependency injection (via Dagger 2 for example) in modules.

This way:

  • modules are fully independent
  • modules declare the dependencies they need
  • modules declare the states they correspond to
  • modules declare the events that can be triggered
  • the hosting application sets up the states it uses (i.e., "screens")
  • the hosting application sets up how to navigation between states (with events)
  • the hosting application sets up the dependency injection mechanism

One of the fastest caching libraries for Java. Lots of features for advanced integrations of external systems: (Variable entry) expiry, exception handling with configurable resilience, loaders/writers, events, statistics. Configuration can also be done via XML (optional feature).

SimpleTabBar is customizable tab bar for viewpager

A Dialog fragment with date pickers which can be used to select a time range.

Tab Stacker is an Android library that handles Multiple Fragment History (Back Stacks), like it is done on iOS Apps.

Simplified Android Rest API wrapper on-top of okHttp

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