az_player_plugin 0.0.6

  • Readme
  • Changelog
  • Example
  • Installing
  • new66

az_player_plugin #

A flutter player plugin for Android and iOS.

This plugin handle background mode playing, for music and video.

Add notification player in notification center and lock screen. Support both android/iOS.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Android #

Step 1. android/app/AndroidManifest.xml

1.1. add code below:

`<service android:name="pro.zahedi.flutter.plugin.player.az_player_plugin.AudioService"

 android:enabled="true"
 android:exported="false">

`

1.2. in Application section:

android:usesCleartextTraffic="true"

1.3. in Application section, add the permission for foreground service:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

Step 2. android/app/build.graddle

2.1. Add the following dependency

`android { compileOptions {

                sourceCompatibility JavaVersion.VERSION_1_8
                targetCompatibility JavaVersion.VERSION_1_8
            }
    }`

Troubleshooting #

Android X compatibility. #

If you have an error about android x compatibility, please visit the Flutter AndroidX compatibility.

iOS #

Step 1. Background mode #

Active background mode in show as a picture:

background mode

Step 2. ios/Runner/Info.plist

Before the </dict> </plist> add:

2.1. Allow access the internet for play link:

`

  <dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
  </dict>
  `
  

2.2. Allow show embedded flutter view:

`

    <true/>
    `
    

Step 3. #

3.1. Choose the application name.

3.2. Minimum SDK is 10.0

minimum sdk

Troubleshooting #

The base flutter project must be swift project.

If you want to migrate to swift project from objective-c. It's easy, you can follow this step in Stack overflow

Usage #

See here for usage.

TODO: #

  • [ ] get play list

  • [ ] fast forward in iOS

  • [ ] fast backward in iOS

  • [ ] handle update client. like call back or interval for update timer, slider, play/pause button in framework.

Please rate/star and contribute if you find it helpfull. #

0.0.6 #

  • Get current file

0.0.5 #

  • Update readme

0.0.4 #

  • Update readme

0.0.3 #

  • Update readme

0.0.2 #

  • Update readme

0.0.1 #

  • Initial

example/README.md

az_player_plugin_example #

You can follow and see git hub repository.

Please rate/start and contribute if find it helpful.

Usage #

import package:

import 'package:az_player_plugin/az_player_plugin.dart' as AZPlayerPlugin;

Define File #

var file = AZPlayerPlugin.File( 0, "http://dl11.f2m.co/trailer/Crawl.2019.360p.Trailer.Film2Movie_WS.mp4", "title", 0, AZPlayerPlugin.FileStatus.ready, "https://cdn.aparnik.com/static/website/img/logo-persian.png", );

Add file to play list #

  1. Add one file:

AZPlayerPlugin.AzPlayerPlugin().addFileToPlayList(file);

  1. Add multi file:

AZPlayerPlugin.AzPlayerPlugin().addFilesToPlayList([file]);

Note: file/files append together in playlist.

Core functionality #

  1. play :

AZPlayerPlugin.AzPlayerPlugin().play();

or

AZPlayerPlugin.AzPlayerPlugin().AZPlayerPlugin.AzPlayerPlugin().playWithFile(file);

  1. pause:

AZPlayerPlugin.AzPlayerPlugin().pause();

  1. get total time of file is playing:

AZPlayerPlugin.AzPlayerPlugin().duration;

  1. get time left:

AZPlayerPlugin.AzPlayerPlugin().secondsLeft;

  1. get current time:

AZPlayerPlugin.AzPlayerPlugin().currentTime;

  1. file is playing?

AZPlayerPlugin.AzPlayerPlugin().isPlaying;

  1. get player view to attach your custom view:

AZPlayerPlugin.AzPlayerPlugin().getPlayerView(width: 300, height: 100);

or

AZPlayerPlugin.AzPlayerPlugin().getPlayerView();

  1. stop:

AZPlayerPlugin.AzPlayerPlugin().stop();

  1. fastForward, current time +15 seconds:

AZPlayerPlugin.AzPlayerPlugin().fastForward();

  1. fastBackward, current time - 5 seconds:

AZPlayerPlugin.AzPlayerPlugin().fastForward();

  1. emptyPlayList, command for delete all files in playlist:

AZPlayerPlugin.AzPlayerPlugin().emptyPlayList();

  1. removeFromPlayList, remove special file from playlist:

AZPlayerPlugin.AzPlayerPlugin().removeFromPlayList(file);

  1. next track:

AZPlayerPlugin.AzPlayerPlugin().next();

  1. previous track:

AZPlayerPlugin.AzPlayerPlugin().previous();

  1. change time to special second:

AZPlayerPlugin.AzPlayerPlugin().changeTime(17);

You must read every one seconds to update your player, like (slider, timer and etc to update time).

Use this package as a library

1. Depend on it

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


dependencies:
  az_player_plugin: ^0.0.6

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:az_player_plugin/az_player_plugin.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
44
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
66
Learn more about scoring.

We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Document public APIs. (-0.62 points)

77 out of 78 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/player_plugin.dart. (-0.50 points)

Analysis of lib/player_plugin.dart reported 1 hint:

line 105 col 86: Avoid empty statements.

Format lib/file.dart.

Run flutter format to format lib/file.dart.

Format lib/file_status.dart.

Run flutter format to format lib/file_status.dart.

Format lib/interfaces/interface_player.dart.

Run flutter format to format lib/interfaces/interface_player.dart.

Format lib/interfaces/interfaces.dart.

Run flutter format to format lib/interfaces/interfaces.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test