From 685d0e6926cc19c90aba2cb338b4048ee46b4e81 Mon Sep 17 00:00:00 2001 From: Naomi Watanabe Date: Sun, 29 Sep 2024 18:41:44 +0900 Subject: [PATCH 1/7] [video_player_avfoundation] Support the HLS (.m3u8) audio on iOS --- packages/video_player/video_player_avfoundation/CHANGELOG.md | 4 ++++ .../Sources/video_player_avfoundation/FVPVideoPlayer.m | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/video_player/video_player_avfoundation/CHANGELOG.md b/packages/video_player/video_player_avfoundation/CHANGELOG.md index 55d1435a118..33b75de77e6 100644 --- a/packages/video_player/video_player_avfoundation/CHANGELOG.md +++ b/packages/video_player/video_player_avfoundation/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.6.5 + +* Supports the audio-only HLS (.m3u8) on iOS. + ## 2.6.4 * Refactors native code structure. diff --git a/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m b/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m index 31573da4039..6633b085bf4 100644 --- a/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m +++ b/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m @@ -383,7 +383,7 @@ - (void)setupEventSinkIfReadyToPlay { } BOOL hasVideoTracks = [asset tracksWithMediaType:AVMediaTypeVideo].count != 0; - BOOL hasNoTracks = asset.tracks.count == 0; + 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 From 1bbee91d6ae2f8337ab6e41a23b8ee43a205f760 Mon Sep 17 00:00:00 2001 From: Naomi Watanabe Date: Tue, 15 Oct 2024 18:43:42 +0900 Subject: [PATCH 2/7] Add a native test for supporting HLS (.m3u8) audio --- .../darwin/RunnerTests/VideoPlayerTests.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/video_player/video_player_avfoundation/darwin/RunnerTests/VideoPlayerTests.m b/packages/video_player/video_player_avfoundation/darwin/RunnerTests/VideoPlayerTests.m index 02b9199a74f..f35d38bd989 100644 --- a/packages/video_player/video_player_avfoundation/darwin/RunnerTests/VideoPlayerTests.m +++ b/packages/video_player/video_player_avfoundation/darwin/RunnerTests/VideoPlayerTests.m @@ -530,6 +530,22 @@ - (void)testHLSControls { XCTAssertEqualWithAccuracy([videoInitialization[@"duration"] intValue], 4000, 200); } +- (void)testAudioOnlyHLSControls { + NSObject *registrar = + [GetPluginRegistry() registrarForPlugin:@"TestAudioOnlyHLSControls"]; + + FVPVideoPlayerPlugin *videoPlayerPlugin = + (FVPVideoPlayerPlugin *)[[FVPVideoPlayerPlugin alloc] initWithRegistrar:registrar]; + + NSDictionary *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]; From a7ff3ad6a997f93ca94a290a3b74aba587a9326d Mon Sep 17 00:00:00 2001 From: Naomi Watanabe Date: Thu, 21 Nov 2024 10:16:09 +0900 Subject: [PATCH 3/7] Tweak the CHANGELOG --- packages/video_player/video_player_avfoundation/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player_avfoundation/CHANGELOG.md b/packages/video_player/video_player_avfoundation/CHANGELOG.md index 33b75de77e6..eff85341000 100644 --- a/packages/video_player/video_player_avfoundation/CHANGELOG.md +++ b/packages/video_player/video_player_avfoundation/CHANGELOG.md @@ -1,6 +1,6 @@ ## 2.6.5 -* Supports the audio-only HLS (.m3u8) on iOS. +* Bugfix to allow the audio-only HLS (.m3u8) on iOS. ## 2.6.4 From 86c0ee094f74201bb59a036617d023c10ae8df57 Mon Sep 17 00:00:00 2001 From: Naomi Watanabe Date: Thu, 21 Nov 2024 13:44:29 +0900 Subject: [PATCH 4/7] Add clarification comment for checking HLS audio-only tracks --- .../Sources/video_player_avfoundation/FVPVideoPlayer.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m b/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m index 6633b085bf4..f24a1827cf8 100644 --- a/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m +++ b/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m @@ -383,6 +383,8 @@ - (void)setupEventSinkIfReadyToPlay { } BOOL hasVideoTracks = [asset tracksWithMediaType:AVMediaTypeVideo].count != 0; + // In HLS streams, AVAsset may not always provide track information because it is a streaming format. + // For audio-only HLS files, track information must be checked using `currentItem.tracks.count`. 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. From e1f409caf12b1f8d55224d13f5c755a040a2400a Mon Sep 17 00:00:00 2001 From: Naomi Watanabe Date: Thu, 5 Dec 2024 09:45:39 +0900 Subject: [PATCH 5/7] Improve the comment for checking HLS audio-only tracks --- .../Sources/video_player_avfoundation/FVPVideoPlayer.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m b/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m index f24a1827cf8..518edfe2339 100644 --- a/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m +++ b/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m @@ -383,8 +383,8 @@ - (void)setupEventSinkIfReadyToPlay { } BOOL hasVideoTracks = [asset tracksWithMediaType:AVMediaTypeVideo].count != 0; - // In HLS streams, AVAsset may not always provide track information because it is a streaming format. - // For audio-only HLS files, track information must be checked using `currentItem.tracks.count`. + // 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. From eb3692561a86099a6a8e7b8caa139573dd8b782d Mon Sep 17 00:00:00 2001 From: Naomi Watanabe Date: Tue, 10 Dec 2024 15:02:05 +0900 Subject: [PATCH 6/7] Format code --- .../Sources/video_player_avfoundation/FVPVideoPlayer.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m b/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m index 518edfe2339..5892274a37d 100644 --- a/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m +++ b/packages/video_player/video_player_avfoundation/darwin/video_player_avfoundation/Sources/video_player_avfoundation/FVPVideoPlayer.m @@ -383,8 +383,8 @@ - (void)setupEventSinkIfReadyToPlay { } BOOL hasVideoTracks = [asset tracksWithMediaType:AVMediaTypeVideo].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. + // 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. From 772da8f1bb26e30e75276f6516f347e9c1e6357a Mon Sep 17 00:00:00 2001 From: Naomi Watanabe Date: Tue, 10 Dec 2024 15:02:32 +0900 Subject: [PATCH 7/7] Update the version --- packages/video_player/video_player_avfoundation/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player_avfoundation/pubspec.yaml b/packages/video_player/video_player_avfoundation/pubspec.yaml index 233a9b65e86..632e59f60fd 100644 --- a/packages/video_player/video_player_avfoundation/pubspec.yaml +++ b/packages/video_player/video_player_avfoundation/pubspec.yaml @@ -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