Skip to content
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
4 changes: 3 additions & 1 deletion flutter_vlc_player/example/lib/controls_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ class ControlsOverlay extends StatelessWidget {
});

@override
// ignore: cyclomatic_complexity
Widget build(BuildContext context) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 50),
reverseDuration: const Duration(milliseconds: 200),
child: Builder(
builder: (ctx) {
builder: (_) {
if (controller.value.isEnded || controller.value.hasError) {
return Center(
child: FittedBox(
Expand Down Expand Up @@ -113,6 +114,7 @@ class ControlsOverlay extends StatelessWidget {
}

Future<void> _pause() async {
// ignore: prefer_early_return
if (controller.value.isPlaying) {
await controller.pause();
}
Expand Down
7 changes: 4 additions & 3 deletions flutter_vlc_player/example/lib/multiple_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class MultipleTab extends StatefulWidget {
class _MultipleTabState extends State<MultipleTab> {
static const _heightWithControls = 400.0;
static const _heightWithoutControls = 300.0;
static const _networkCachingTime = 2000;

List<VlcPlayerController> controllers = <VlcPlayerController>[];

Expand All @@ -31,7 +32,7 @@ class _MultipleTabState extends State<MultipleTab> {
autoPlay: false,
options: VlcPlayerOptions(
advanced: VlcAdvancedOptions([
VlcAdvancedOptions.networkCaching(2000),
VlcAdvancedOptions.networkCaching(_networkCachingTime),
]),
rtp: VlcRtpOptions([
VlcRtpOptions.rtpOverRtsp(true),
Expand All @@ -46,7 +47,7 @@ class _MultipleTabState extends State<MultipleTab> {
Widget build(BuildContext context) {
return ListView.separated(
itemCount: controllers.length,
separatorBuilder: (_, index) {
separatorBuilder: (_, __) {
return const Divider(height: 5, thickness: 5, color: Colors.grey);
},
itemBuilder: (_, index) {
Expand All @@ -64,10 +65,10 @@ class _MultipleTabState extends State<MultipleTab> {

@override
Future<void> dispose() async {
super.dispose();
for (final controller in controllers) {
await controller.stopRendererScanning();
await controller.dispose();
}
super.dispose();
}
}
17 changes: 8 additions & 9 deletions flutter_vlc_player/example/lib/single_tab.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// ignore_for_file: cyclomatic_complexity
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_vlc_player/flutter_vlc_player.dart';
Expand All @@ -19,7 +21,7 @@ class _SingleTabState extends State<SingleTab> {

final _key = GlobalKey<VlcPlayerWithControlsState>();

// ignore: avoid-late-keyword
// ignore: avoid_late_keyword
late final VlcPlayerController _controller;

//
Expand Down Expand Up @@ -120,7 +122,10 @@ class _SingleTabState extends State<SingleTab> {
await _controller.startRendererScanning();
});
_controller.addOnRendererEventListener((type, id, name) {
debugPrint('OnRendererEventListener $type $id $name');
// ignore: prefer_early_return
if (!kReleaseMode) {
debugPrint('OnRendererEventListener $type $id $name');
}
});
}

Expand Down Expand Up @@ -258,15 +263,9 @@ class _SingleTabState extends State<SingleTab> {

@override
Future<void> dispose() async {
super.dispose();
await _controller.stopRecording();
await _controller.stopRendererScanning();
await _controller.dispose();
super.dispose();
}
}

class MyClass {
final int _myField = 0;

int get myField => _myField;
}
19 changes: 10 additions & 9 deletions flutter_vlc_player/example/lib/vlc_player_with_controls.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// ignore_for_file: prefer_early_return, function_lines_of_code
import 'dart:typed_data';

import 'package:flutter/material.dart';
Expand Down Expand Up @@ -36,7 +37,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls> {
final double initSnapshotRightPosition = 10;
final double initSnapshotBottomPosition = 10;

// ignore: avoid-late-keyword
// ignore: avoid_late_keyword
late VlcPlayerController _controller;

//
Expand Down Expand Up @@ -363,7 +364,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls> {
IconButton(
icon: const Icon(Icons.fullscreen),
color: Colors.white,
// ignore: no-empty-block
// ignore: no_empty_block
onPressed: () {},
),
],
Expand Down Expand Up @@ -456,7 +457,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls> {
if (!mounted) return;
final selectedSubId = await showDialog<int>(
context: context,
builder: (BuildContext context) {
builder: (BuildContext _) {
return AlertDialog(
title: const Text('Select Subtitle'),
content: SizedBox(
Expand Down Expand Up @@ -502,7 +503,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls> {
if (!mounted) return;
final selectedAudioTrackId = await showDialog<int>(
context: context,
builder: (BuildContext context) {
builder: (BuildContext _) {
return AlertDialog(
title: const Text('Select Audio'),
content: SizedBox(
Expand Down Expand Up @@ -546,7 +547,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls> {
if (!mounted) return;
final selectedCastDeviceName = await showDialog<String>(
context: context,
builder: (BuildContext context) {
builder: (BuildContext _) {
return AlertDialog(
title: const Text('Display Devices'),
content: SizedBox(
Expand Down Expand Up @@ -596,7 +597,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls> {

if (!mounted) return;

// ignore: avoid-non-null-assertion
// ignore: avoid_non_null_assertion
Overlay.of(context).insert(_overlayEntry!);
}

Expand All @@ -617,7 +618,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls> {
_overlayEntry = null;
await showDialog<void>(
context: context,
builder: (ctx) {
builder: (_) {
return AlertDialog(
contentPadding: EdgeInsets.zero,
content: Image.memory(snapshot),
Expand All @@ -633,7 +634,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls> {
right -= dragUpdateDetails.delta.dx;
_overlayEntry?.markNeedsBuild();
},
onHorizontalDragEnd: (dragEndDetails) {
onHorizontalDragEnd: (_) {
if ((initSnapshotRightPosition - right).abs() >= _overlayWidth) {
_overlayEntry?.remove();
_overlayEntry = null;
Expand All @@ -642,7 +643,7 @@ class VlcPlayerWithControlsState extends State<VlcPlayerWithControls> {
_overlayEntry?.markNeedsBuild();
}
},
onVerticalDragEnd: (dragEndDetails) {
onVerticalDragEnd: (_) {
if ((initSnapshotBottomPosition - bottom).abs() >=
_overlayWidth) {
_overlayEntry?.remove();
Expand Down
4 changes: 2 additions & 2 deletions flutter_vlc_player/lib/src/flutter_vlc_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_vlc_player/src/vlc_player_controller.dart';
import 'package:flutter_vlc_player/src/vlc_player_platform.dart';

// ignore: prefer-match-file-name
// ignore: prefer_match_file_name
class VlcPlayer extends StatefulWidget {
final VlcPlayerController controller;
final double aspectRatio;
Expand Down Expand Up @@ -36,7 +36,7 @@ class VlcPlayer extends StatefulWidget {
class _VlcPlayerState extends State<VlcPlayer> {
bool _isInitialized = false;

//ignore: avoid-late-keyword
//ignore: avoid_late_keyword
late VoidCallback _listener;

_VlcPlayerState() {
Expand Down
5 changes: 3 additions & 2 deletions flutter_vlc_player/lib/src/vlc_player_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
bool? _isReadyToInitialize;

/// The viewId for this controller
// ignore: avoid-late-keyword
// ignore: avoid_late_keyword
late int _viewId;

/// List of onInit listeners
Expand Down Expand Up @@ -351,9 +351,9 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
_onRendererEventListeners.clear();
_lifeCycleObserver?.dispose();
_isDisposed = true;
super.dispose();
//
await vlcPlayerPlatform.dispose(_viewId);
super.dispose();
}

/// Notify onInit callback & all registered listeners
Expand Down Expand Up @@ -953,6 +953,7 @@ class VlcPlayerController extends ValueNotifier<VlcPlayerValue> {
'$functionName() was called on an uninitialized VlcPlayerController.',
);
}
// ignore: prefer_early_return
if (_isDisposed) {
throw Exception(
'$functionName() was called on a disposed VlcPlayerController.',
Expand Down
1 change: 1 addition & 0 deletions flutter_vlc_player/lib/src/vlc_player_value.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class VlcPlayerValue {

/// Returns a new instance that has the same values as this current instance,
/// except for any overrides passed in as arguments to [copyWidth].
// ignore: number_of_parameters
VlcPlayerValue copyWith({
Duration? duration,
Size? size,
Expand Down
2 changes: 1 addition & 1 deletion flutter_vlc_player/pigeons/messages.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:pigeon/pigeon_lib.dart';

//ignore: prefer-match-file-name
//ignore: prefer_match_file_name
class ViewMessage {
int? viewId;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// ignore: prefer-match-file-name
// ignore: prefer_match_file_name
enum HwAcc { auto, disabled, decoding, full }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// ignore: prefer-match-file-name
// ignore: prefer_match_file_name
enum VlcMediaEventType {
opening,
playing,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// ignore: prefer-match-file-name
// ignore: prefer_match_file_name
enum VlcRendererEventType { attached, detached, unknown }
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:ui';

import 'package:flutter_vlc_player_platform_interface/src/enums/media_event_type.dart';

// ignore: prefer-match-file-name
// ignore: prefer_match_file_name
class VlcMediaEvent {
/// The type of the event.
final VlcMediaEventType mediaEventType;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter_vlc_player_platform_interface/src/enums/renderer_event_type.dart';

// ignore: prefer-match-file-name
// ignore: prefer_match_file_name
class VlcRendererEvent {
/// The type of the event.
final VlcRendererEventType eventType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class MethodChannelVlcPlayer extends VlcPlayerPlatform {
return _api.create(message);
}

// ignore: proper_super_calls
@override
Future<void> dispose(int viewId) async {
return _api.dispose(ViewMessage()..viewId = viewId);
Expand Down Expand Up @@ -76,7 +77,7 @@ class MethodChannelVlcPlayer extends VlcPlayerPlatform {
: PlatformViewLink(
viewType: viewType,
surfaceFactory: (
BuildContext context,
BuildContext _,
PlatformViewController controller,
) {
return AndroidViewSurface(
Expand Down Expand Up @@ -110,6 +111,7 @@ class MethodChannelVlcPlayer extends VlcPlayerPlatform {
}

@override
// ignore: cyclomatic_complexity
Stream<VlcMediaEvent> mediaEventsFor(int viewId) {
return _mediaEventChannelFor(viewId).receiveBroadcastStream().map((
dynamic event,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:flutter_vlc_player_platform_interface/flutter_vlc_player_platfor
import 'package:flutter_vlc_player_platform_interface/src/method_channel/method_channel_vlc_player.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

// ignore_for_file: prefer-match-file-name
// ignore_for_file: prefer_match_file_name

/// The interface that implementations of vlc must implement.
///
Expand All @@ -32,6 +32,7 @@ abstract class VlcPlayerPlatform extends PlatformInterface {
/// Constructs a VlcPlayerPlatform.
VlcPlayerPlatform() : super(token: _token);

// ignore: avoid_returning_widgets
/// Returns a widget displaying the video.
Widget buildView(
PlatformViewCreatedCallback onPlatformViewCreated, {
Expand Down