Skip to content

moda20/flutter_media_notification

 
 

Repository files navigation

media_notification

Media notification for flutter, on Android Only (iOS Not implemented)

This plugin is used in the music player app TuneIn.

please star this repository or TuneIn, i am open to comments and possible features.

You can contact me using my email "[email protected]" or the info at the end of this ReadMe

Usage

Main functions

You can call the show method to show the media controls like follow :

Show Function

    ByteData dibd = await rootBundle.load("images/image.png");
    List<int> defaultImageBytes = dibd.buffer.asUint8List();

try {
      await MediaNotification.show( 
        title: title, // the title of the track
        author: author, // a subtitle usually the artist
        image:"/storage/emulated/0/Pictures/Reddit/c4c7164.jpg", // an image, Must be a URI
        bgImage: "/storage/emulated/0/Pictures/Reddit/c4c7164.jpg", // an image that is show on the lower part of (ONLY) the BIG View 
        bgBitmapImage: defaultImageBytes // the lower part image but in bytes form, can get over any permission problems 
        bgImageBackgroundColor:Colors.red, // The background color of the lower part if the image doesn't fill it completely
        BitmapImage: defaultImageBytes, // an image in bytes form, can get over any permission problems 
        bgColor: Colors.deepPurple, // the background Color of the notification panel
        iconColor: Colors.blue, // The control icons colors
        bigLayoutIconColor: Colors.greenAccent, // controls Icon color for the big layout. if not set the iconColor would be used instead
        subtitleColor: Colors.deepOrange, // The subtitle color
        titleColor: Colors.orange, // the title color
        timeStamp: "23:23" // The timestamp tat will be shown 
      );
    } on PlatformException {

    }

Hide Function

You can call the hide method to hide the Media controls like follow :

MediaNotification.hide();

Extra functions and listeners

You can use the next functions and listeners n order to further polish the experience of using the plugin

Extra Functions

MediaNotification.setTo(false); must take a boolean argument, will set the play/pause button icon accordingly : 1- True means currently playing, will set the icon to Pause icon 2- False means currently on pause or stop ( no distinction between the two ), will set the icon to Play icon

MediaNotification.togglePlayPause(); takes no arguments, will automatically toggle the play/pause button icon

MediaNotification.setSubtitle(SubtitleString); must take a String argument will change the subtitle on the notification to the given string

MediaNotification.setTitle(TitleString); must take a String argument will change the title on the notification to the given string

MediaNotification.setTimestamp(Timestamp); must take a String argument will change the shown timestamp on the notification to the given string

MediaNotification.setStatusIcon(IconString); must take a String argument will change the icon on the Statusbar to the given string *IconString argument must be the path to the icon in the res folder. i.e : "drawable/baseline_play_arrow_black_48"

Extra Listeners

The following listeners can be used to listen on the different control buttons when tapped

MediaNotification.setListener('play', () {
      print("playing shoud slart playin"); // will be triggered when the Play arrow button is tapped
    });

    MediaNotification.setListener('pause', () {
      print("playback should pause"); // will be triggered when the Pause Bars button is tapped
    });

    MediaNotification.setListener('next', () {
      print("playback should go to next track"); // will be triggered when the next button is tapped
    });

    MediaNotification.setListener('prev', () {
       print("playback should go to previous track"); // will be triggered when the previous button is tapped
    });

    MediaNotification.setListener('select', () {
      print("selected Notification"); // will be triggered when the notification is selected (tapped) from the notification area
    });

Screenshots

Notification Area Lock Screen Notification Area

Getting Started With the flutter plugin development

For help getting started with Flutter, view our online documentation.

For help on editing plugin code, view the documentation.

Support me

You can support me by:

⭐️ this repo if you like it.

Buy me a cup of coffee ☕️:

NOT there yet

Contact me & Hire Me

email: [email protected]

Thank you in advance 👍

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 67.1%
  • Dart 21.9%
  • Ruby 7.1%
  • Objective-C 3.9%