Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
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: 4 additions & 0 deletions packages/video_player/video_player/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.1.8

* Refactor `FLTCMTimeToMillis` to support indefinite streams. Fixes [#48670](https://github.com/flutter/flutter/issues/48670).

## 2.1.7

* Update exoplayer to 2.14.1, removing dependency on Bintray.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,23 @@ void main() {
skip: !(kIsWeb || defaultTargetPlatform == TargetPlatform.android),
);

testWidgets(
'live stream duration != 0',
(WidgetTester tester) async {
VideoPlayerController networkController = VideoPlayerController.network(
'https://cph-p2p-msl.akamaized.net/hls/live/2000341/test/master.m3u8',
);
await networkController.initialize();

expect(networkController.value.isInitialized, true);
// Live streams should have either a positive duration or C.TIME_UNSET if the duration is unknown
// See https://exoplayer.dev/doc/reference/com/google/android/exoplayer2/Player.html#getDuration--
expect(networkController.value.duration,
(Duration duration) => duration != Duration.zero);
},
skip: (kIsWeb),
);

testWidgets(
'can be played',
(WidgetTester tester) async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
#error Code Requires ARC.
#endif

int64_t FLTCMTimeToMillis(CMTime time) {
if (time.timescale == 0) return 0;
return time.value * 1000 / time.timescale;
}

@interface FLTFrameUpdater : NSObject
@property(nonatomic) int64_t textureId;
@property(nonatomic, weak, readonly) NSObject<FlutterTextureRegistry>* registry;
Expand Down Expand Up @@ -107,6 +102,16 @@ - (void)itemDidPlayToEndTime:(NSNotification*)notification {
}
}

const int64_t TIME_UNSET = -9223372036854775807;

static inline int64_t FLTCMTimeToMillis(CMTime time) {
// When CMTIME_IS_INDEFINITE return a value that matches TIME_UNSET from ExoPlayer2 on Android.
// Fixes https://github.com/flutter/flutter/issues/48670
if (CMTIME_IS_INDEFINITE(time)) return TIME_UNSET;
if (time.timescale == 0) return 0;
return time.value * 1000 / time.timescale;
}

static inline CGFloat radiansToDegrees(CGFloat radians) {
// Input range [-pi, pi] or [-180, 180]
CGFloat degrees = GLKMathRadiansToDegrees((float)radians);
Expand Down
2 changes: 1 addition & 1 deletion packages/video_player/video_player/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for displaying inline video with other Flutter
widgets on Android, iOS, and web.
repository: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.1.7
version: 2.1.8

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down