Skip to content

Commit 3a481ff

Browse files
refactor
1 parent 7c7d04d commit 3a481ff

File tree

6 files changed

+18
-25
lines changed

6 files changed

+18
-25
lines changed

.github/workflows/code_check_for_flutter_vlc_player_platform_interface.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ jobs:
99
- uses: actions/checkout@v1
1010

1111
- name: Setup flutter
12-
if: steps.check_files.outputs.files_exists == 'true'
1312
uses: subosito/flutter-action@v2
1413
with:
1514
channel: 'stable'

flutter_vlc_player/example/lib/single_tab.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class SingleTab extends StatefulWidget {
1313
}
1414

1515
class _SingleTabState extends State<SingleTab> {
16-
static const _networkCaching = 2000;
16+
static const _networkCachingMs = 2000;
1717
static const _subtitlesFontSize = 30;
1818
static const _height = 400.0;
1919

@@ -86,7 +86,7 @@ class _SingleTabState extends State<SingleTab> {
8686
hwAcc: HwAcc.full,
8787
options: VlcPlayerOptions(
8888
advanced: VlcAdvancedOptions([
89-
VlcAdvancedOptions.networkCaching(_networkCaching),
89+
VlcAdvancedOptions.networkCaching(_networkCachingMs),
9090
]),
9191
subtitle: VlcSubtitleOptions([
9292
VlcSubtitleOptions.boldStyle(true),

flutter_vlc_player/example/lib/vlc_player_with_controls.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
3131
static const _recordingPositionOffset = 10.0;
3232
static const _positionedBottomSpace = 7.0;
3333
static const _positionedRightSpace = 3.0;
34-
static const _hundred = 100.0;
34+
static const _overlayWidth = 100.0;
3535
static const _elevation = 4.0;
3636
static const _aspectRatio = 16 / 9;
37-
static const _thousand = 1000;
3837

3938
final double initSnapshotRightPosition = 10;
4039
final double initSnapshotBottomPosition = 10;
@@ -400,7 +399,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
400399
Expanded(
401400
child: Slider(
402401
min: 0,
403-
max: _hundred,
402+
max: _overlayWidth,
404403
value: volumeValue,
405404
onChanged: _setSoundVolume,
406405
),
@@ -454,7 +453,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
454453
sliderValue = progress.floor().toDouble();
455454
});
456455
//convert to Milliseconds since VLC requires MS to set time
457-
_controller.setTime(sliderValue.toInt() * _thousand);
456+
_controller.setTime(sliderValue.toInt() * Duration.millisecondsPerSecond);
458457
}
459458

460459
Future<void> _getSubtitleTracks() async {
@@ -607,7 +606,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
607606
builder: (context) => Positioned(
608607
right: right,
609608
bottom: bottom,
610-
width: _hundred,
609+
width: _overlayWidth,
611610
child: Material(
612611
elevation: _elevation,
613612
child: GestureDetector(
@@ -633,7 +632,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
633632
_overlayEntry.markNeedsBuild();
634633
},
635634
onHorizontalDragEnd: (dragEndDetails) {
636-
if ((initSnapshotRightPosition - right).abs() >= _hundred) {
635+
if ((initSnapshotRightPosition - right).abs() >= _overlayWidth) {
637636
_overlayEntry?.remove();
638637
_overlayEntry = null;
639638
} else {
@@ -642,7 +641,8 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls>
642641
}
643642
},
644643
onVerticalDragEnd: (dragEndDetails) {
645-
if ((initSnapshotBottomPosition - bottom).abs() >= _hundred) {
644+
if ((initSnapshotBottomPosition - bottom).abs() >=
645+
_overlayWidth) {
646646
_overlayEntry?.remove();
647647
_overlayEntry = null;
648648
} else {

flutter_vlc_player/lib/src/vlc_player_controller.dart

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// ignore_for_file: lines_longer_than_80_chars, comment_references
2-
31
import 'dart:async';
42
import 'dart:io';
53

@@ -179,8 +177,7 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
179177
throw Exception('Already Initialized');
180178
}
181179

182-
_lifeCycleObserver = VlcAppLifeCycleObserver(this);
183-
_lifeCycleObserver?.initialize();
180+
_lifeCycleObserver = VlcAppLifeCycleObserver(this)..initialize();
184181

185182
await vlcPlayerPlatform.create(
186183
viewId: _viewId,
@@ -369,9 +366,7 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
369366

370367
/// Notify onInit callback & all registered listeners
371368
void _notifyOnInitListeners() {
372-
if (_onInit != null) {
373-
_onInit?.call();
374-
}
369+
_onInit?.call();
375370
for (final listener in _onInitListeners) {
376371
listener();
377372
}
@@ -384,9 +379,7 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
384379
String? name,
385380
) {
386381
if (id == null || name == null) return;
387-
if (_onRendererHandler != null) {
388-
_onRendererHandler?.call(type, id, name);
389-
}
382+
_onRendererHandler?.call(type, id, name);
390383
for (final listener in _onRendererEventListeners) {
391384
listener(type, id, name);
392385
}
@@ -507,7 +500,7 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
507500
}
508501

509502
/// Sets whether or not the video should loop after playing once.
510-
Future<void> setLooping({required bool looping}) async {
503+
Future<void> setLooping(bool looping) async {
511504
_throwIfNotInitialized('setLooping');
512505
value = value.copyWith(isLooping: looping);
513506
await vlcPlayerPlatform.setLooping(_viewId, looping);

flutter_vlc_player_platform_interface/lib/src/method_channel/method_channel_vlc_player.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ class MethodChannelVlcPlayer extends VlcPlayerPlatform {
114114
Stream<VlcMediaEvent> mediaEventsFor(int viewId) {
115115
return _mediaEventChannelFor(viewId).receiveBroadcastStream().map(
116116
(dynamic event) {
117-
final Map<Object?, Object?> map = event as Map<Object?, Object?>;
117+
final Map<String, Object?> map = event as Map<String, Object?>;
118118
//
119119
switch (map['event']) {
120120
case 'opening':

flutter_vlc_player_platform_interface/lib/src/utils/helpers/subtitles/vlc_subtitle_color.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
class VlcSubtitleColor {
2-
static const _redShiftAmount = 16;
3-
static const _greenShiftAmount = 8;
2+
static const _bitsInByte = 8;
3+
static const _redHexOffset = 2 * _bitsInByte;
4+
static const _greenHexOffset = _bitsInByte;
45
static const black = VlcSubtitleColor(0);
56
static const gray = VlcSubtitleColor(8421504);
67
static const silver = VlcSubtitleColor(12632256);
@@ -24,5 +25,5 @@ class VlcSubtitleColor {
2425
int red = 0,
2526
int green = 0,
2627
int blue = 0,
27-
}) : value = (red << _redShiftAmount) + (green << _greenShiftAmount) + blue;
28+
}) : value = (red << _redHexOffset) + (green << _greenHexOffset) + blue;
2829
}

0 commit comments

Comments
 (0)