8000 fix changing video quality by sha3rawi33 · Pull Request #188 · appinioGmbH/flutter_packages · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix changing video quality #188

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
Binary file removed assets/widget_zoom/zoom.gif
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion 31
namespace = "com.example.example"
compileSdkVersion 34

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
Expand All @@ -44,7 +45,7 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 16
minSdkVersion flutter.minSdkVersion
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
17 changes: 14 additions & 3 deletions packages/appinio_video_player/example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
buildscript {
ext.kotlin_version = '1.6.21'
ext.kotlin_version = '1.7.10'
repositories {
google()
mavenCentral()
}

dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath 'com.android.tools.build:gradle:8.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -18,12 +18,23 @@ allprojects {
}
}

subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
72 changes: 48 additions & 24 deletions packages/appinio_video_player/example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: "4a07be6cb69c84d677a6c3096fcf960cc3285a8330b4603e0d463d15d9bd934c"
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.17.1"
version: "1.18.0"
csslib:
dependency: transitive
description:
Expand Down Expand Up @@ -103,14 +103,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.15.0"
js:
leak_tracker:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
name: leak_tracker
sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
url: "https://pub.dev"
source: hosted
version: "0.6.7"
version: "10.0.5"
leak_tracker_flutter_testing:
dependency: transitive
description:
name: leak_tracker_flutter_testing
sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
url: "https://pub.dev"
source: hosted
version: "3.0.5"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev"
source: hosted
version: "3.0.1"
lints:
dependency: transitive
description:
Expand All @@ -123,34 +139,34 @@ packages:
dependency: transitive
description:
name: matcher
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
url: "https://pub.dev"
source: hosted
version: "0.12.15"
version: "0.12.16+1"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724
sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
url: "https://pub.dev"
source: hosted
version: "0.2.0"
version: "0.11.1"
meta:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.15.0"
path:
dependency: transitive
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
plugin_platform_interface:
dependency: transitive
description:
Expand All @@ -168,26 +184,26 @@ packages:
dependency: transitive
description:
name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.dev"
source: hosted
version: "1.11.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.1.2"
string_scanner:
dependency: transitive
description:
Expand All @@ -208,10 +224,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "0.7.2"
vector_math:
dependency: transitive
description:
Expand Down Expand Up @@ -260,6 +276,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.0.7"
vm_service:
dependency: transitive
description:
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.5"
sdks:
dart: ">=3.0.0-0 <4.0.0"
flutter: ">=2.10.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.18.0-18.0.pre.54"
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class _VideoSettingsQualityDialogState
return widget.customVideoPlayerController.additionalVideoSources!.entries
.toList()
.firstWhere((element) =>
element.value ==
widget.customVideoPlayerController.videoPlayerController)
element.value.dataSource ==
widget.customVideoPlayerController.videoPlayerController.dataSource)
.key;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import 'dart:async';

import 'package:appinio_video_player/src/fullscreen_video_player.dart';
import 'package:appinio_video_player/src/models/custom_video_player_settings.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:video_player/video_player.dart';
import 'package:appinio_video_player/src/models/custom_video_player_settings.dart';

/// The extension on the class is able to call private methods
/// only the package can use these methods and not the public beacuse of the hide keyword in the package exports
Expand All @@ -14,8 +15,7 @@ extension ProtectedCustomVideoPlayerController on CustomVideoPlayerController {
ValueNotifier<double> get playbackSpeedNotifier => _playbackSpeedNotifier;
ValueNotifier<bool> get isPlayingNotifier => _isPlayingNotifier;
bool get isFullscreen => _isFullscreen;
set updateViewAfterFullscreen(Function updateViewAfterFullscreen) =>
_updateViewAfterFullscreen = updateViewAfterFullscreen;
set updateViewAfterFullscreen(Function updateViewAfterFullscreen) => _updateViewAfterFullscreen = updateViewAfterFullscreen;
}

class CustomVideoPlayerController {
Expand All @@ -24,12 +24,14 @@ class CustomVideoPlayerController {
final CustomVideoPlayerSettings customVideoPlayerSettings;
final Map<String, VideoPlayerController>? additionalVideoSources;
final ValueNotifier<bool> areControlsVisible = ValueNotifier<bool>(true);
Widget? watermarkWidget;

CustomVideoPlayerController({
required this.context,
required this.videoPlayerController,
this.customVideoPlayerSettings = const CustomVideoPlayerSettings(),
this.additionalVideoSources,
this.watermarkWidget,
}) {
videoPlayerController.addListener(_videoListeners);
}
Expand All @@ -41,8 +43,7 @@ class CustomVideoPlayerController {
bool fullscreen,
) async {
if (kIsWeb) {
debugPrint(
"Web doesn't support fullscreen properly. When exiting fullscreen the video will be black. Audio still works.");
debugPrint("Web doesn't support fullscreen properly. When exiting fullscreen the video will be black. Audio still works.");
}
if (fullscreen) {
await _enterFullscreen();
Expand All @@ -58,8 +59,7 @@ class CustomVideoPlayerController {

bool _isFullscreen = false;
Timer? _timer;
final ValueNotifier<Duration> _videoProgressNotifier =
ValueNotifier(Duration.zero);
final ValueNotifier<Duration> _videoProgressNotifier = ValueNotifier(Duration.zero);
final ValueNotifier<double> _playbackSpeedNotifier = ValueNotifier(1.0);
final ValueNotifier<bool> _isPlayingNotifier = ValueNotifier(false);

Expand All @@ -78,8 +78,7 @@ class CustomVideoPlayerController {
);
_isFullscreen = true;
_setOrientationForVideo();
SystemChrome.setEnabledSystemUIMode(
customVideoPlayerSettings.systemUIModeInsideFullscreen);
SystemChrome.setEnabledSystemUIMode(customVideoPlayerSettings.systemUIModeInsideFullscreen);
await Navigator.of(context).push(route);
}

Expand All @@ -89,8 +88,7 @@ class CustomVideoPlayerController {
customVideoPlayerSettings.systemUIModeAfterFullscreen,
overlays: customVideoPlayerSettings.systemUIOverlaysAfterFullscreen,
);
await SystemChrome.setPreferredOrientations(customVideoPlayerSettings
.deviceOrientationsAfterFullscreen); // reset device orientation values
await SystemChrome.setPreferredOrientations(customVideoPlayerSettings.deviceOrientationsAfterFullscreen); // reset device orientation values
_isFullscreen = false;
Navigator.of(context).pop();
}
Expand Down Expand Up @@ -133,17 +131,15 @@ class CustomVideoPlayerController {
videoPlayerController.removeListener(_videoListeners);
videoPlayerController = newSource;
await videoPlayerController.initialize();
videoPlayerController.addListener(
_videoListeners); // add listeners to new video controller
videoPlayerController.addListener(_videoListeners); // add listeners to new video controller
if (isFullscreen) {
_setOrientationForVideo(); // if video changed completely
}
await videoPlayerController.seekTo(_playedDuration);
if (Theme.of(context).platform != TargetPlatform.iOS) {
await videoPlayerController.setPlaybackSpeed(_playbackSpeed);
} else {
await videoPlayerController.setPlaybackSpeed(
1); // resetting to 1 because its not working on iOS. open issue on github
await videoPlayerController.setPlaybackSpeed(1); // resetting to 1 because its not working on iOS. open issue on github
}
if (_wasPlaying) {
await videoPlayerController.play();
Expand All @@ -164,20 +160,17 @@ class CustomVideoPlayerController {
/// used to make progress more fluid
Future<void> _fluidVideoProgressListener() async {
if (videoPlayerController.value.isPlaying) {
_timer ??= Timer.periodic(const Duration(milliseconds: 100),
(Timer timer) async {
_timer ??= Timer.periodic(const Duration(milliseconds: 100), (Timer timer) async {
if (videoPlayerController.value.isInitialized) {
_videoProgressNotifier.value = await videoPlayerController.position ??
_videoProgressNotifier.value;
_videoProgressNotifier.value = await videoPlayerController.position ?? _videoProgressNotifier.value;
}
});
} else {
if (_timer != null) {
_timer?.cancel();
_timer = null;
if (videoPlayerController.value.isInitialized) {
_videoProgressNotifier.value =
(await videoPlayerController.position)!;
_videoProgressNotifier.value = (await videoPlayerController.position)!;
}
}
}
Expand All @@ -186,28 +179,20 @@ class CustomVideoPlayerController {
/// save that the video is played once
void _onVideoEndListener() {
if (videoPlayerController.value.position > Duration.zero) {
if (videoPlayerController.value.duration ==
videoPlayerController.value.position) {
if (videoPlayerController.value.duration == videoPlayerController.value.position) {
playedOnceNotifier.value = true;
}
}
}

void _fullscreenFunctionalityListener() {
// exit fullscreen on end
if (videoPlayerController.value.duration ==
videoPlayerController.value.position &&
!videoPlayerController.value.isPlaying &&
customVideoPlayerSettings.exitFullscreenOnEnd &&
_isFullscreen) {
if (videoPlayerController.value.duration == videoPlayerController.value.position && !videoPlayerController.value.isPlaying && customVideoPlayerSettings.exitFullscreenOnEnd && _isFullscreen) {
setFullscreen(false);
}

// enter fullscreen on start
if (videoPlayerController.value.position == Duration.zero &&
videoPlayerController.value.isPlaying &&
customVideoPlayerSettings.enterFullscreenOnStart &&
!_isFullscreen) {
if (videoPlayerController.value.position == Duration.zero && videoPlayerController.value.isPlaying && customVideoPlayerSettings.enterFullscreenOnStart && !_isFullscreen) {
setFullscreen(true);
}
}
Expand Down Expand Up @@ -236,8 +221,7 @@ class CustomVideoPlayerController {
videoPlayerController.dispose();
if (additionalVideoSources != null) {
if (additionalVideoSources!.isNotEmpty) {
for (MapEntry<String, VideoPlayerController> videoSource
in additionalVideoSources!.entries) {
for (MapEntry<String, VideoPlayerController> videoSource in additionalVideoSources!.entries) {
videoSource.value.dispose();
}
}
Expand Down
Loading
0