Skip to content

Commit

Permalink
chore: few fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MSOB7YY committed Oct 13, 2023
1 parent 5b53f97 commit 261e46a
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
6 changes: 5 additions & 1 deletion lib/controller/audio_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,8 @@ class NamidaAudioVideoHandler<Q extends Playable> extends BasicAudioHandler<Q> {
streams.audioOnlyStreams?.firstWhereEff((e) => e.formatSuffix != 'webm') ??
streams.audioOnlyStreams?.firstOrNull;
if (prefferedAudioStream?.url != null || prefferedVideoStream?.url != null) {
final isStreamRequiredBetterThanCachedSet = playedFromCacheDetails.$2 != null && (prefferedVideoStream?.width ?? 0) > (playedFromCacheDetails.$2?.width ?? 0);
final isStreamRequiredBetterThanCachedSet =
playedFromCacheDetails.$2 == null ? true : playedFromCacheDetails.$2 != null && (prefferedVideoStream?.width ?? 0) > (playedFromCacheDetails.$2?.width ?? 0);

currentVideoStream.value = isStreamRequiredBetterThanCachedSet ? prefferedVideoStream : vos?.firstWhereEff((e) => e.width == (playedFromCacheDetails.$2?.width));

Expand Down Expand Up @@ -1113,6 +1114,9 @@ class NamidaAudioVideoHandler<Q extends Playable> extends BasicAudioHandler<Q> {
},
youtubeID: (finalItem) async {
await plsPause();
if (position == Duration.zero) {
// -- try putting cache version if it was cached
}
await plsSeek();
},
);
Expand Down
4 changes: 2 additions & 2 deletions lib/controller/search_sort_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ class SearchSortController {
final tsf = settings.trackSearchFilter;
final cleanup = settings.enableSearchCleanup.value;
final result = await _searchTracksIsolate.thready({
'tsf': tsf,
'tsf': tsf.toList(),
'cleanup': cleanup,
'tracks': tracksInfoList,
'tracks': tracksInfoList.toList(),
'text': text,
});
final finalList = temp ? trackSearchTemp : trackSearchList;
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/widgets/custom_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ class NamidaWheelSlider<T> extends StatelessWidget {
initValue: initValue,
itemSize: itemSize,
squeeze: squeeze,
isInfinite: false,
isInfinite: isInfinite,
lineColor: Get.iconColor,
pointerColor: context.theme.listTileTheme.textColor!,
pointerHeight: 38.0,
Expand Down
1 change: 1 addition & 0 deletions lib/ui/widgets/settings/advanced_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ class __ClearImageCacheListTileState extends State<_ClearImageCacheListTile> {
onPressed: () async {
NamidaNavigator.inst.closeDialog();
await Indexer.inst.clearImageCache();
_fillSizes();
},
);
},
Expand Down
30 changes: 20 additions & 10 deletions lib/ui/widgets/video_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,20 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
upperBound: 1.0,
);

FlutterVolumeController.addListener(
(value) async {
if (widget.showControls) {
final ast = await FlutterVolumeController.getAndroidAudioStream();
if (ast == AudioStream.music) {
_currentDeviceVolume.value = value;
if (widget.isFullScreen) {
FlutterVolumeController.addListener(
(value) async {
if (widget.showControls) {
final ast = await FlutterVolumeController.getAndroidAudioStream();
if (ast == AudioStream.music) {
_currentDeviceVolume.value = value;
if (!_isPointerDown) _startVolumeSwipeTimer(); // only start timer if not handled by pointer down/up
}
}
}
},
emitOnStart: false,
);
},
emitOnStart: false,
);
}
}

@override
Expand Down Expand Up @@ -417,8 +420,12 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
return isSafeFromDown && isSafeFromUp;
}

/// used to disable slider if user swiped too close to the edge.
bool _disableSliderVolume = false;

/// used to hide slider if wasnt handled by pointer down/up.
bool _isPointerDown = false;

@override
Widget build(BuildContext context) {
final dummyWidget = widget.fallbackChild ??
Expand All @@ -433,18 +440,21 @@ class NamidaVideoControlsState extends State<NamidaVideoControls> with TickerPro
return Listener(
behavior: HitTestBehavior.translucent,
onPointerCancel: (event) {
_isPointerDown = false;
_disableSliderVolume = false;
if (shouldShowVolumeSlider) {
_startVolumeSwipeTimer();
}
},
onPointerUp: (event) {
_isPointerDown = false;
_disableSliderVolume = false;
if (shouldShowVolumeSlider) {
_startVolumeSwipeTimer();
}
},
onPointerDown: (event) {
_isPointerDown = true;
if (_shouldSeekOnTap) {
_onDoubleTap(event.position);
_startTimer();
Expand Down

0 comments on commit 261e46a

Please sign in to comment.