Skip to content
Merged
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
24 changes: 4 additions & 20 deletions lib/cached_video_player_plus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import 'package:video_player_platform_interface/video_player_platform_interface.
import 'src/closed_caption_file.dart';

export 'package:video_player_platform_interface/video_player_platform_interface.dart'
show DurationRange, DataSourceType, VideoFormat, VideoPlayerOptions;
show DataSourceType, DurationRange, VideoFormat, VideoPlayerOptions;

export 'src/closed_caption_file.dart';

Expand Down Expand Up @@ -373,7 +373,7 @@ class CachedVideoPlayerPlusController
final String dataSource;

/// HTTP headers used for the request to the [dataSource].
/// Only for [CachedVideoPlayerPlusController.network].
/// Only for [CachedVideoPlayerPlusController.networkUrl].
/// Always empty for other video types.
final Map<String, String> httpHeaders;

Expand Down Expand Up @@ -507,7 +507,6 @@ class CachedVideoPlayerPlusController
asset: realDataSource,
package: package,
);
break;
case DataSourceType.network:
dataSourceDescription = DataSource(
sourceType: _isCachingSupported && isCacheAvailable
Expand All @@ -517,20 +516,17 @@ class CachedVideoPlayerPlusController
formatHint: formatHint,
httpHeaders: httpHeaders,
);
break;
case DataSourceType.file:
dataSourceDescription = DataSource(
sourceType: DataSourceType.file,
uri: realDataSource,
httpHeaders: httpHeaders,
);
break;
case DataSourceType.contentUri:
dataSourceDescription = DataSource(
sourceType: DataSourceType.contentUri,
uri: realDataSource,
);
break;
}

if (videoPlayerOptions?.mixWithOthers != null) {
Expand Down Expand Up @@ -563,24 +559,19 @@ class CachedVideoPlayerPlusController
_applyLooping();
_applyVolume();
_applyPlayPause();
break;
case VideoEventType.completed:
// In this case we need to stop _timer, set isPlaying=false, and
// position=value.duration. Instead of setting the values directly,
// we use pause() and seekTo() to ensure the platform stops playing
// and seeks to the last frame of the video.
pause().then((void pauseResult) => seekTo(value.duration));
value = value.copyWith(isCompleted: true);
break;
case VideoEventType.bufferingUpdate:
value = value.copyWith(buffered: event.buffered);
break;
case VideoEventType.bufferingStart:
value = value.copyWith(isBuffering: true);
break;
case VideoEventType.bufferingEnd:
value = value.copyWith(isBuffering: false);
break;
case VideoEventType.isPlayingStateUpdate:
if (event.isPlaying ?? false) {
value = value.copyWith(
Expand All @@ -590,7 +581,6 @@ class CachedVideoPlayerPlusController
} else {
value = value.copyWith(isPlaying: event.isPlaying);
}
break;
case VideoEventType.unknown:
break;
}
Expand Down Expand Up @@ -885,7 +875,7 @@ class _VideoAppLifeCycleObserver extends Object with WidgetsBindingObserver {
final CachedVideoPlayerPlusController _controller;

void initialize() {
_ambiguate(WidgetsBinding.instance)!.addObserver(this);
WidgetsBinding.instance.addObserver(this);
}

@override
Expand All @@ -901,7 +891,7 @@ class _VideoAppLifeCycleObserver extends Object with WidgetsBindingObserver {
}

void dispose() {
_ambiguate(WidgetsBinding.instance)!.removeObserver(this);
WidgetsBinding.instance.removeObserver(this);
}
}

Expand Down Expand Up @@ -1289,9 +1279,3 @@ class ClosedCaption extends StatelessWidget {
);
}
}

/// This allows a value of type T or T? to be treated as a value of type T?.
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
T? _ambiguate<T>(T? value) => value;