az_player_plugin 0.0.3 az_player_plugin: ^0.0.3 copied to clipboard
A Flutter player plugin
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:
Step 2. ios/Runner/Info.plist
Before the </dict> </plist>
add:
2.1. Allow access the internet for play link:
``
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>``
2.2. Allow show embedded flutter view:
<key>io.flutter.embedded_views_preview</key> <true/>
Step 3.
3.1. Choose the application name.
3.2. Minimum SDK
is 10.0
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 #
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 #
- Add one file:
AZPlayerPlugin.AzPlayerPlugin().addFileToPlayList(file);
- Add multi file:
AZPlayerPlugin.AzPlayerPlugin().addFilesToPlayList([file]);
Note: file/files append together in playlist.
Core functionality #
- play :
AZPlayerPlugin.AzPlayerPlugin().play();
AZPlayerPlugin.AzPlayerPlugin().AZPlayerPlugin.AzPlayerPlugin().playWithFile(file);
- pause:
AZPlayerPlugin.AzPlayerPlugin().pause();
- get total time of file is playing:
AZPlayerPlugin.AzPlayerPlugin().duration;
- get time left:
AZPlayerPlugin.AzPlayerPlugin().secondsLeft;
- get current time:
AZPlayerPlugin.AzPlayerPlugin().currentTime;
- file is playing?
AZPlayerPlugin.AzPlayerPlugin().isPlaying;
- get player view to attach your custom view:
AZPlayerPlugin.AzPlayerPlugin().getPlayerView(width: 300, height: 100);
or
AZPlayerPlugin.AzPlayerPlugin().getPlayerView();
- stop:
AZPlayerPlugin.AzPlayerPlugin().stop();
- fastForward, current time +15 seconds:
AZPlayerPlugin.AzPlayerPlugin().fastForward();
- fastBackward, current time - 5 seconds:
AZPlayerPlugin.AzPlayerPlugin().fastForward();
- emptyPlayList, command for delete all files in playlist:
AZPlayerPlugin.AzPlayerPlugin().emptyPlayList();
- removeFromPlayList, remove special file from playlist:
AZPlayerPlugin.AzPlayerPlugin().removeFromPlayList(file);
- next track:
AZPlayerPlugin.AzPlayerPlugin().next();
- previous track:
AZPlayerPlugin.AzPlayerPlugin().previous();
- 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).
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.