AnonymHK / betterplayer

Bug fix version for betterplayer
Apache License 2.0
43 stars 35 forks source link

[BUG] HLS Quality (track) change doesn't work on IOS #10

Open bazmichael opened 1 year ago

bazmichael commented 1 year ago

History check Yes - I've searched all the issues. Fount the single one (no answers at all) in the original, abandoned repository.

Describe the bug If you change the quality while streaming on iOS, nothing happens, unless you manually seek to another point in the video. This works fine on Android.

To Reproduce Steps to reproduce the behavior:

Play a video Invoke the Quality pop-up Change to lower quality Observe nothing changes Manually seek using the slider bar - see the quality change Expected behavior Quality should change after being selected (as it does on Android correctly)

Workarounds I've tried

Listen to changedTrack event pause video, seekTo time + 1/-1, play doesn't work as per manual seeking.

Flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.10.5, on macOS 13.4 22F66 darwin-arm64, locale en-PL) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 14.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] IntelliJ IDEA Community Edition (version 2021.3.3) [✓] VS Code (version 1.77.3) [✓] Connected device (4 available) [✓] Network resources

Better Player version Version: 0.0.83 Smartphone (please complete the following information):

Device: iPhone12 OS: 16

bazmichael commented 1 year ago

This is a piece of native IOS (BetterPlayer.m) code, which seems to be not working.

- (void)setTrackParameters:(int) width: (int) height: (int)bitrate {
    _player.currentItem.preferredPeakBitRate = bitrate;
    if (@available(iOS 11.0, *)) {
        if (width == 0 && height == 0){
            _player.currentItem.preferredMaximumResolution = CGSizeZero;
        } else {
            _player.currentItem.preferredMaximumResolution = CGSizeMake(width, height);
        }
    }
}
bazmichael commented 1 year ago

Apple developer reference: https://developer.apple.com/forums/thread/675282

pavankumar-clasc commented 1 year ago

History check Yes - I've searched all the issues. Fount the single one (no answers at all) in the original, abandoned repository.

Describe the bug If you change the quality while streaming on iOS, nothing happens, unless you manually seek to another point in the video. This works fine on Android.

To Reproduce Steps to reproduce the behavior:

Play a video Invoke the Quality pop-up Change to lower quality Observe nothing changes Manually seek using the slider bar - see the quality change Expected behavior Quality should change after being selected (as it does on Android correctly)

Workarounds I've tried

Listen to changedTrack event pause video, seekTo time + 1/-1, play doesn't work as per manual seeking.

Flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.10.5, on macOS 13.4 22F66 darwin-arm64, locale en-PL) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 14.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] IntelliJ IDEA Community Edition (version 2021.3.3) [✓] VS Code (version 1.77.3) [✓] Connected device (4 available) [✓] Network resources

Better Player version Version: 0.0.83 Smartphone (please complete the following information):

Device: iPhone12 OS: 16

Facing the same issue. Looking for solution to fix this.

bazmichael commented 1 year ago

Seems like we need to dive into AVVideoComposition, which is the object of AVPlayerItem.

https://developer.apple.com/documentation/avfoundation/avvideocomposition