Change version to 0.2.0

This commit is contained in:
stonegate 2020-04-24 12:19:56 +08:00
parent 60e066d2a9
commit 599fc75647
4 changed files with 46 additions and 18 deletions

View File

@ -47,7 +47,7 @@ android {
applicationId "com.stonegate.tsacdop" applicationId "com.stonegate.tsacdop"
minSdkVersion 19 minSdkVersion 19
targetSdkVersion 28 targetSdkVersion 28
versionCode 4 versionCode 5
versionName flutterVersionName versionName flutterVersionName
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@ -348,18 +348,20 @@ class AudioPlayerNotifier extends ChangeNotifier {
notifyListeners(); notifyListeners();
}); });
double s = _currentSpeed ?? 1.0; //double s = _currentSpeed ?? 1.0;
int getPosition = 0; int getPosition = 0;
Timer.periodic(Duration(milliseconds: 500), (timer) { Timer.periodic(Duration(milliseconds: 200), (timer) {
double s = _currentSpeed ?? 1.0;
if (_noSlide) { if (_noSlide) {
if (_audioState == BasicPlaybackState.playing) { if (_audioState == BasicPlaybackState.playing) {
getPosition = _currentPosition + getPosition = _currentPosition +
(DateTime.now().difference(_current).inMilliseconds * s).toInt(); ((DateTime.now().difference(_current).inMilliseconds) * s)
.toInt();
_backgroundAudioPosition = getPosition < _backgroundAudioDuration _backgroundAudioPosition = getPosition < _backgroundAudioDuration
? getPosition ? getPosition
: _backgroundAudioDuration; : _backgroundAudioDuration;
} else } else
_backgroundAudioPosition = _currentPosition; _backgroundAudioPosition = _currentPosition ?? 0;
if (_backgroundAudioDuration != null && if (_backgroundAudioDuration != null &&
_backgroundAudioDuration != 0 && _backgroundAudioDuration != 0 &&
@ -618,6 +620,7 @@ class AudioPlayerTask extends BackgroundAudioTask {
_setState( _setState(
state: state, state: state,
position: event.position.inMilliseconds, position: event.position.inMilliseconds,
speed: event.speed,
); );
} }
}); });
@ -666,7 +669,8 @@ class AudioPlayerTask extends BackgroundAudioTask {
_skipState = null; _skipState = null;
// Resume playback if we were playing // Resume playback if we were playing
// if (_playing) { // if (_playing) {
onPlay(); //onPlay();
playFromStart();
// } else { // } else {
// _setState(state: BasicPlaybackState.paused); // _setState(state: BasicPlaybackState.paused);
// } // }
@ -684,6 +688,7 @@ class AudioPlayerTask extends BackgroundAudioTask {
if (duration != null) if (duration != null)
await AudioServiceBackground.setMediaItem( await AudioServiceBackground.setMediaItem(
mediaItem.copyWith(duration: duration.inMilliseconds)); mediaItem.copyWith(duration: duration.inMilliseconds));
playFromStart();
} }
// if (mediaItem.extras['skip'] > 0) { // if (mediaItem.extras['skip'] > 0) {
// await _audioPlayer.setClip( // await _audioPlayer.setClip(
@ -691,14 +696,27 @@ class AudioPlayerTask extends BackgroundAudioTask {
// print(mediaItem.extras['skip']); // print(mediaItem.extras['skip']);
// print('set clip success'); // print('set clip success');
// } // }
else else {
_playing = true; _playing = true;
await _audioPlayer.play(); if (_audioPlayer.playbackEvent.state != AudioPlaybackState.connecting &&
_audioPlayer.playbackEvent.state != AudioPlaybackState.none)
_audioPlayer.play();
}
// if (mediaItem.extras['skip'] >
// _audioPlayer.playbackEvent.position.inSeconds ??
// 0) {
// _audioPlayer.seek(Duration(seconds: mediaItem.extras['skip']));
// }
}
}
playFromStart() async {
_playing = true;
_audioPlayer.play();
if (mediaItem.extras['skip'] > 0) { if (mediaItem.extras['skip'] > 0) {
_audioPlayer.seek(Duration(seconds: mediaItem.extras['skip'])); _audioPlayer.seek(Duration(seconds: mediaItem.extras['skip']));
} }
} }
}
@override @override
void onPause() { void onPause() {
@ -711,6 +729,8 @@ class AudioPlayerTask extends BackgroundAudioTask {
@override @override
void onSeekTo(int position) { void onSeekTo(int position) {
if (_audioPlayer.playbackEvent.state != AudioPlaybackState.connecting &&
_audioPlayer.playbackEvent.state != AudioPlaybackState.none)
_audioPlayer.seek(Duration(milliseconds: position)); _audioPlayer.seek(Duration(milliseconds: position));
} }
@ -751,7 +771,8 @@ class AudioPlayerTask extends BackgroundAudioTask {
Duration duration = await _audioPlayer.durationFuture ?? Duration.zero; Duration duration = await _audioPlayer.durationFuture ?? Duration.zero;
AudioServiceBackground.setMediaItem( AudioServiceBackground.setMediaItem(
mediaItem.copyWith(duration: duration.inMilliseconds)); mediaItem.copyWith(duration: duration.inMilliseconds));
onPlay(); playFromStart();
//onPlay();
} else { } else {
_queue.insert(index, mediaItem); _queue.insert(index, mediaItem);
await AudioServiceBackground.setQueue(_queue); await AudioServiceBackground.setQueue(_queue);
@ -807,15 +828,20 @@ class AudioPlayerTask extends BackgroundAudioTask {
} }
} }
void _setState({@required BasicPlaybackState state, int position}) { void _setState(
{@required BasicPlaybackState state, int position, double speed}) {
if (position == null) { if (position == null) {
position = _audioPlayer.playbackEvent.position.inMilliseconds; position = _audioPlayer.playbackEvent.position.inMilliseconds;
} }
if (speed == null) {
speed = _audioPlayer.playbackEvent.speed;
}
AudioServiceBackground.setState( AudioServiceBackground.setState(
controls: getControls(state), controls: getControls(state),
systemActions: [MediaAction.seekTo], systemActions: [MediaAction.seekTo],
basicState: state, basicState: state,
position: position, position: position,
speed: speed,
); );
} }

View File

@ -3,6 +3,8 @@ import 'package:flutter/services.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
import 'package:line_icons/line_icons.dart'; import 'package:line_icons/line_icons.dart';
const String version = '0.2.0';
class AboutApp extends StatelessWidget { class AboutApp extends StatelessWidget {
_launchUrl(String url) async { _launchUrl(String url) async {
if (await canLaunch(url)) { if (await canLaunch(url)) {
@ -72,7 +74,7 @@ class AboutApp extends StatelessWidget {
image: AssetImage('assets/logo.png'), image: AssetImage('assets/logo.png'),
height: 80, height: 80,
), ),
Text('Version: 0.2.0'), Text('Version: $version'),
], ],
), ),
), ),

View File

@ -11,7 +11,7 @@ description: An easy-use podacasts player.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at # Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.1.9 version: 0.2.0
environment: environment:
sdk: ">=2.6.0 <3.0.0" sdk: ">=2.6.0 <3.0.0"