在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):rxlabz/audioplayer开源软件地址(OpenSource Url):https://github.com/rxlabz/audioplayer开源编程语言(OpenSource Language):Dart 46.0%开源软件介绍(OpenSource Introduction):AudioPlayerA Flutter audio plugin (Swift/Java) to play remote or local audio files on iOS / Android / MacOS and Web. Features
UsageTo use this plugin :
dependencies:
flutter:
sdk: flutter
audioplayer: 0.8.1
audioplayer_web: 0.7.1
//...
AudioPlayer audioPlugin = AudioPlayer();
//... Player ControlsaudioPlayer.play(url);
audioPlayer.pause();
audioPlayer.stop(); Status and current positionThe dart part of the plugin listen for platform calls : //...
_positionSubscription = audioPlayer.onAudioPositionChanged.listen(
(p) => setState(() => position = p)
);
_audioPlayerStateSubscription = audioPlayer.onPlayerStateChanged.listen((s) {
if (s == AudioPlayerState.PLAYING) {
setState(() => duration = audioPlayer.duration);
} else if (s == AudioPlayerState.STOPPED) {
onComplete();
setState(() {
position = duration;
});
}
}, onError: (msg) {
setState(() {
playerState = PlayerState.stopped;
duration = new Duration(seconds: 0);
position = new Duration(seconds: 0);
});
}); Do not forget to cancel all the subscriptions when the widget is disposed. iOS
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论