Skip to content
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

August/September changes #709

Merged
merged 38 commits into from
Sep 20, 2021
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
d179ab7
Added expandToFill parameter in BetterPlayerConfiguration
jhomlala Aug 22, 2021
7e99110
Updated changelog
jhomlala Aug 22, 2021
e44c3af
* Added `BetterPlayerControlsConfiguration.theme` factory for `Better…
jhomlala Aug 22, 2021
44acd92
Added null checks in seek commands in BetterPlayerControlsState.
jhomlala Aug 25, 2021
63ef709
Fixed issue with live stream where player controls were always visible.
jhomlala Aug 25, 2021
0337016
Updated tests
jhomlala Aug 26, 2021
4bf8f2a
Updated tests
jhomlala Aug 26, 2021
718e940
Updated tests
jhomlala Aug 29, 2021
1a28c84
Updated tests
jhomlala Aug 29, 2021
1e78931
Updated tests
jhomlala Aug 29, 2021
d783b36
Added tests to CI
jhomlala Aug 29, 2021
d6af2b3
Update ci.yml
jhomlala Aug 29, 2021
8236245
Updated tests
jhomlala Aug 29, 2021
8dac048
Updated tests
jhomlala Aug 29, 2021
f39fb09
Merge remote-tracking branch 'origin/feature/august_changes_2' into f…
jhomlala Aug 29, 2021
8d1edf2
Updated tests
jhomlala Aug 29, 2021
2efd4b6
Updated tests
jhomlala Aug 29, 2021
42c2270
Updated tests, general refactor
jhomlala Aug 29, 2021
6856204
Updated cupertino theme
jhomlala Aug 31, 2021
a0ec2db
Fixed iOS seek issue
jhomlala Sep 7, 2021
57a04e0
Fix iOS caching + add iOS feature: preCaching (#670)
Sep 7, 2021
7d92867
Added stop pre cache iOS implementation
jhomlala Sep 7, 2021
e68a09a
Updated caching implementation
jhomlala Sep 8, 2021
210d4d5
Updated caching implementation
jhomlala Sep 8, 2021
bfc8507
Updated caching implementation
jhomlala Sep 8, 2021
ed48d96
Updated caching implementation
jhomlala Sep 12, 2021
d486347
Updated documentation
jhomlala Sep 12, 2021
04f4530
Fixed video FPS hardcoded to 30 on iOs (#705)
antonkrasov Sep 15, 2021
b878227
Updated changelog
jhomlala Sep 15, 2021
55a9672
set default subtitle from hls (#688)
siloebb Sep 15, 2021
24db360
General refactor
jhomlala Sep 15, 2021
f23e8dd
Disabled analysis options.
jhomlala Sep 15, 2021
49248ee
Flutter 2.5 update
jhomlala Sep 16, 2021
ce341ec
Flutter 2.5 update
jhomlala Sep 16, 2021
ab597d5
Disabled lint
jhomlala Sep 16, 2021
d3e21ef
Fixed analyzer
jhomlala Sep 16, 2021
91b8d1c
Updated dependencies
jhomlala Sep 20, 2021
9da6c90
Updated version
jhomlala Sep 20, 2021
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
Prev Previous commit
Next Next commit
Updated tests
  • Loading branch information
jhomlala committed Aug 29, 2021
commit 8dac04852a0f7fa5b4d403e962038caee23593b8
9 changes: 6 additions & 3 deletions lib/src/core/better_player_controller.dart
Original file line number Diff line number Diff line change
@@ -672,15 +672,18 @@ class BetterPlayerController {
///Set volume of player. Allows values from 0.0 to 1.0.
Future<void> setVolume(double volume) async {
if (volume < 0.0 || volume > 1.0) {
BetterPlayerUtils.log("Volume must be between 0.0 and 1.0");
throw ArgumentError("Volume must be between 0.0 and 1.0");
}
if (videoPlayerController == null) {
BetterPlayerUtils.log("The data source has not been initialized");
return;
throw StateError("The data source has not been initialized");
}
await videoPlayerController!.setVolume(volume);
_postEvent(BetterPlayerEvent(BetterPlayerEventType.setVolume,
parameters: <String, dynamic>{_volumeParameter: volume}));
_postEvent(BetterPlayerEvent(
BetterPlayerEventType.setVolume,
parameters: <String, dynamic>{_volumeParameter: volume},
));
}

///Set playback speed of video. Allows to set speed value between 0 and 2.
73 changes: 71 additions & 2 deletions test/better_player_controller_test.dart
Original file line number Diff line number Diff line change
@@ -64,7 +64,7 @@ void main() {
);

test(
"seek should change player position",
"seekTo should change player position",
() async {
final BetterPlayerController betterPlayerController =
BetterPlayerTestUtils.setupBetterPlayerMockController();
@@ -83,6 +83,36 @@ void main() {
},
);

test(
"seekTo should send event",
() async {
final BetterPlayerController betterPlayerController =
BetterPlayerTestUtils.setupBetterPlayerMockController();
final videoPlayerController =
BetterPlayerTestUtils.setupMockVideoPlayerControler();
videoPlayerController.setDuration(const Duration(seconds: 100));
betterPlayerController.videoPlayerController = videoPlayerController;

int seekEventCalls = 0;
int finishEventCalls = 0;
betterPlayerController.addEventsListener((event) {
if (event.betterPlayerEventType == BetterPlayerEventType.seekTo) {
seekEventCalls += 1;
}
if (event.betterPlayerEventType == BetterPlayerEventType.finished) {
finishEventCalls += 1;
}
});
betterPlayerController.seekTo(const Duration(seconds: 5));
await Future.delayed(const Duration(milliseconds: 100), () {});
expect(seekEventCalls, 1);
betterPlayerController.seekTo(const Duration(seconds: 150));
await Future.delayed(const Duration(milliseconds: 100), () {});
expect(seekEventCalls, 2);
expect(finishEventCalls, 1);
},
);

test("full screen and auto play should work", () async {
final BetterPlayerMockController betterPlayerMockController =
BetterPlayerMockController(
@@ -244,7 +274,6 @@ void main() {
BetterPlayerTestUtils.setupBetterPlayerMockController();
betterPlayerMockController.addEventsListener((event) {});
betterPlayerMockController.addEventsListener((event) {});
//There's also additional internal listener.
expect(betterPlayerMockController.eventListeners.length, 2);
});

@@ -259,6 +288,46 @@ void main() {
betterPlayerMockController.removeEventsListener(dummyEventListener);
expect(betterPlayerMockController.eventListeners.length, 1);
});

test("setVolume changes volume", () async {
final mockVideoPlayerController = MockVideoPlayerController();
final BetterPlayerMockController betterPlayerMockController =
BetterPlayerTestUtils.setupBetterPlayerMockController();
mockVideoPlayerController
.setNetworkDataSource(BetterPlayerTestUtils.bugBuckBunnyVideoUrl);
betterPlayerMockController.videoPlayerController =
mockVideoPlayerController;
betterPlayerMockController.setVolume(1.0);
expect(mockVideoPlayerController.volume, 1.0);
betterPlayerMockController.setVolume(0.5);
expect(mockVideoPlayerController.volume, 0.5);
});

test(
"setVolume should send event",
() async {
final BetterPlayerController betterPlayerMockController =
BetterPlayerTestUtils.setupBetterPlayerMockController();
final videoPlayerController =
BetterPlayerTestUtils.setupMockVideoPlayerControler();
betterPlayerMockController.videoPlayerController =
videoPlayerController;

int setVolumeCalls = 0;
betterPlayerMockController.addEventsListener((event) {
if (event.betterPlayerEventType ==
BetterPlayerEventType.setVolume) {
setVolumeCalls += 1;
}
});
betterPlayerMockController.setVolume(1.0);
await Future.delayed(const Duration(milliseconds: 100), () {});
expect(setVolumeCalls, 1);
betterPlayerMockController.setVolume(1.0);
await Future.delayed(const Duration(milliseconds: 100), () {});
expect(setVolumeCalls, 2);
},
);
},
);
}
12 changes: 8 additions & 4 deletions test/mock_video_player_controller.dart
Original file line number Diff line number Diff line change
@@ -2,13 +2,12 @@ import 'package:better_player/src/video_player/video_player.dart';
import 'package:better_player/src/video_player/video_player_platform_interface.dart';

class MockVideoPlayerController extends VideoPlayerController {
MockVideoPlayerController() : super(autoCreate: false){
value = VideoPlayerValue(duration: const Duration());
MockVideoPlayerController() : super(autoCreate: false) {
value = VideoPlayerValue(duration: const Duration());
}

bool isLoopingState = false;


double volume = 0.0;

@override
Future<void> play() async {
@@ -43,6 +42,11 @@ class MockVideoPlayerController extends VideoPlayerController {
@override
Future<Duration?> get position async => value.position;

@override
Future<void> setVolume(double volume) async {
this.volume = volume;
}

@override
Future<void> setNetworkDataSource(String dataSource,
{VideoFormat? formatHint,