mp3_player 0.2.0

  • Readme
  • Changelog
  • Installing
  • 75

mp3_player #

GitHub repo size GitHub Last Tag GitHub last commit

Support Pub Version

GitHub stars GitHub forks

A library for play mp3 file in ternimal, and it is based on mpg123.

Usage #

  1. add dependency in pubspec.yaml.

  2. then, you can use it in your code:

import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart';

import 'package:mp3_player/audio_player.dart';

void main(List<String> args) async {
  stdin.echoMode = false;
  stdin.lineMode = false;


  var player = await Player.run();
  var dir = dirname(Platform.script.path);
  dir = Platform.isWindows ? dir.substring(1) : dir;
  var song = [
    join(dir, 'sample_mp3/a.mp3'),
    join(dir, 'sample_mp3/b.mp3'),
    join(dir, 'sample_mp3/c.mp3')
  ];
  player.play(song);


  var playing = true;
  stdin.transform(Utf8Decoder()).listen((inputKey) {
    switch (inputKey) {
      case ' ':
        playing ? player.pause() : player.resume();
        print(playing ? 'pause' : 'resume');
        playing = !playing;
        break;
      case '[':
        print('pre');
        player.pre();
        break;
      case ']':
        print('next');
        player.next();
        break;
      case ',':
        print('back');
        player.back();
        break;
      case '.':
        print('forward');
        player.forward();
        break;
      case '-':
        print('down volume');
        player.downVolume();
        break;
      case '=':
        print('up volume');
        player.upVolumne();
        break;
      case 'q':
        print('quit');
        player.quit();
        break;
    }
  });
}

Method #

Player play([dynamic songs]);
Player addSong(dynamic songs);
Player pause();
Player resume();
Player next();
Player pre();
Player forward({int seconds = 5, int frame});
Player back({int seconds = 5, int frame});
Player upVolumne([int delta = 10]);
Player downVolume([int delta = 10]);
void quit();

0.1.0 #

  • complete basic function

0.1.1 #

  • update README

0.1.2 #

  • fix utf8 decoder exception

0.2.0 #

  • update. player add some method to get player info

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  mp3_player: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:mp3_player/audio_player.dart';
import 'package:mp3_player/exception.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
50
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
75
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Analysis suggestions

Package not compatible with runtime flutter-web on web

Because:

  • package:mp3_player/audio_player.dart that imports:
  • dart:io

Package not compatible with runtime js

Because:

  • package:mp3_player/audio_player.dart that imports:
  • dart:io

Health suggestions

Fix lib/src/process_player/mpg123_player.dart. (-1.49 points)

Analysis of lib/src/process_player/mpg123_player.dart reported 3 hints:

line 5 col 10: The value of the field '_os' isn't used.

line 57 col 5: Future results in async function bodies must be awaited or marked unawaited using package:pedantic.

line 67 col 16: The declaration '_load' isn't referenced.

Fix lib/src/interface/i_process_player.dart. (-0.50 points)

Analysis of lib/src/interface/i_process_player.dart reported 1 hint:

line 12 col 11: The declaration '_load' isn't referenced.

Format lib/src/player.dart.

Run dartfmt to format lib/src/player.dart.

Format lib/src/process_player/mpg123_monitor.dart.

Run dartfmt to format lib/src/process_player/mpg123_monitor.dart.

Maintenance suggestions

Maintain an example.

None of the files in the package's example/ directory matches known example patterns.

Common filename patterns include main.dart, example.dart, and mp3_player.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
pedantic ^1.8.0
test ^1.6.0