Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add FijkSlider and cacheValue support #158

Merged
merged 3 commits into from
Jan 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 0 additions & 127 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions android/src/main/java/com/befovy/fijkplayer/FijkPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,11 @@ public void onAudioFocusChange(int focusChange) {
Log.i("FIJKPLAYER", "onAudioFocusChange: " + focusChange);
}

/**
* Set screen on enable or disable
* @param on true to set keep screen on enable
* false to set keep screen on disable
*/
void setScreenOn(boolean on) {
Activity activity = registrar.activity();
if (activity == null || activity.getWindow() == null)
Expand Down
2 changes: 2 additions & 0 deletions lib/fijkplayer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ part 'core/fijkvol.dart';
part 'ui/panel.dart';

part 'ui/volume.dart';

part 'ui/slider.dart';
18 changes: 12 additions & 6 deletions lib/ui/panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class _DefaultFijkPanelState extends State<_DefaultFijkPanel> {

Duration _duration = Duration();
Duration _currentPos = Duration();
Duration _bufferPos = Duration();

bool _playing = false;
bool _prepared = false;
Expand All @@ -82,7 +83,7 @@ class _DefaultFijkPanelState extends State<_DefaultFijkPanel> {

StreamSubscription _currentPosSubs;

//StreamSubscription _bufferPosSubs;
StreamSubscription _bufferPosSubs;
//StreamSubscription _bufferingSubs;

Timer _hideTimer;
Expand All @@ -98,7 +99,7 @@ class _DefaultFijkPanelState extends State<_DefaultFijkPanel> {

_duration = player.value.duration;
_currentPos = player.currentPos;
//_bufferPos = player.bufferPos;
_bufferPos = player.bufferPos;
_prepared = player.state.index >= FijkState.prepared.index;
_playing = player.state == FijkState.started;
_exception = player.value.exception.message;
Expand All @@ -111,6 +112,12 @@ class _DefaultFijkPanelState extends State<_DefaultFijkPanel> {
_currentPos = v;
});
});

_bufferPosSubs = player.onBufferPosUpdate.listen((v) {
setState(() {
_bufferPos = v;
});
});
}

void _playerValueChanged() {
Expand Down Expand Up @@ -150,8 +157,7 @@ class _DefaultFijkPanelState extends State<_DefaultFijkPanel> {

player.removeListener(_playerValueChanged);
_currentPosSubs?.cancel();
//_bufferPosSubs.cancel();
//_bufferingSubs.cancel();
_bufferPosSubs?.cancel();
}

void _startHideTimer() {
Expand Down Expand Up @@ -219,11 +225,11 @@ class _DefaultFijkPanelState extends State<_DefaultFijkPanel> {
: Expanded(
child: Padding(
padding: EdgeInsets.only(right: 0, left: 0),
child: Slider(
child: FijkSlider(
value: currentValue,
cacheValue: _bufferPos.inMilliseconds.toDouble(),
min: 0.0,
max: duration,
label: '$currentValue',
onChanged: (v) {
_startHideTimer();
setState(() {
Expand Down
Loading