Skip to content

[video_player_avfoundation] Support the audio-only HLS (.m3u8) on iOS #7890

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

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
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.6.5

* Bugfix to allow the audio-only HLS (.m3u8) on iOS.

## 2.6.4

* Refactors native code structure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,22 @@ - (void)testHLSControls {
XCTAssertEqualWithAccuracy([videoInitialization[@"duration"] intValue], 4000, 200);
}

- (void)testAudioOnlyHLSControls {
NSObject<FlutterPluginRegistrar> *registrar =
[GetPluginRegistry() registrarForPlugin:@"TestAudioOnlyHLSControls"];

FVPVideoPlayerPlugin *videoPlayerPlugin =
(FVPVideoPlayerPlugin *)[[FVPVideoPlayerPlugin alloc] initWithRegistrar:registrar];

NSDictionary<NSString *, id> *videoInitialization =
[self testPlugin:videoPlayerPlugin
uri:@"https://flutter.github.io/assets-for-api-docs/assets/videos/hls/"
@"bee_audio_only.m3u8"];
XCTAssertEqualObjects(videoInitialization[@"height"], @0);
XCTAssertEqualObjects(videoInitialization[@"width"], @0);
XCTAssertEqualWithAccuracy([videoInitialization[@"duration"] intValue], 4000, 200);
}

#if TARGET_OS_IOS
- (void)testTransformFix {
[self validateTransformFixForOrientation:UIImageOrientationUp];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ - (void)setupEventSinkIfReadyToPlay {
}

BOOL hasVideoTracks = [asset tracksWithMediaType:AVMediaTypeVideo].count != 0;
BOOL hasNoTracks = asset.tracks.count == 0;
// Audio-only HLS files have no size, so `currentItem.tracks.count` must be used to check for
// track presence, as AVAsset does not always provide track information in HLS streams.
BOOL hasNoTracks = currentItem.tracks.count == 0 && asset.tracks.count == 0;

// The player has not yet initialized when it has no size, unless it is an audio-only track.
// HLS m3u8 video files never load any tracks, and are also not yet initialized until they have
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: video_player_avfoundation
description: iOS and macOS implementation of the video_player plugin.
repository: https://github.com/flutter/packages/tree/main/packages/video_player/video_player_avfoundation
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+video_player%22
version: 2.6.4
version: 2.6.5

environment:
sdk: ^3.3.0
Expand Down
Loading