youtube / youtube-ios-player-helper

Lightweight helper library that allows iOS developers to add inline playback of YouTube videos through a WebView
Other
1.64k stars 680 forks source link

No subtitles shown in fullscreen mode. #456

Open marcelderkskarlmax opened 2 years ago

marcelderkskarlmax commented 2 years ago

Hello!

We are using youtube content with subtitles. When playing the videos in embedded mode, these subtitles are correctly displayed. But when switching into fullscreen mode these subtitles are suddenly disappearing and also there is no settings menu visible anymore to toggle them back on.

This is very annoying as users who switch to fullscreen are especially interested in the content but are not able to consume anymore :-/

Tested with iOS 15.2.1 youtube-ios-player-helper (1.0.4)

Player parameters:

[ "controls": 1, "modestbranding": 1, "playsinline": 1, "rel": 0, "showinfo": 0 ]

Thank you! Any help appreciated.

brol1dev commented 2 years ago

Hi @marcelderkskarlmax ,

Can you provide us with the video ids you are having trouble with?

Thank you, we will take a look into it.

marcelderkskarlmax commented 2 years ago

Sure!

For example we are showing this content:

https://www.youtube.com/watch?v=eEqMwv362kM

amill676 commented 2 years ago

I'm seeing the same thing. Also seems to happen when using airplay to stream to another device. I'm guessing it's a related cause.

Same versions/config

jasonszheng commented 2 years ago

Hello @marcelderkskarlmax, I've tried reproducing your issue within our demo application with the same player settings/video id and have been unable to reproduce this issue.

Are you able to reproduce the issue within our demo application. If not, can you provide more detailed instructions on how this is occuring?

marcelderkskarlmax commented 2 years ago

@jasonszheng

Thats interesting. I will try that myself and provide feedback here. Thanks !

marcelderkskarlmax commented 2 years ago

@jasonszheng

I took your example project and played the video id in your SingleVideoViewController and indeed the subtitles work there. So I tried to isolate the problem more.

I added a new ViewController to your example project called SwiftVideoController . There I added the following code which is the way we are using the youtube helper in our project.

import Foundation
import UIKit
import youtube_ios_player_helper

class SwiftVideoPlayer: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let youtubePlayerView = YTPlayerView()

        let playerVars: [String: Any] = [
            "controls": 1,
            "modestbranding": 1,
            "playsinline": 1,
            "rel": 0,
            "showinfo": 1
        ]

        view.addSubview(youtubePlayerView)
        youtubePlayerView.translatesAutoresizingMaskIntoConstraints = false

        NSLayoutConstraint.activate([
            youtubePlayerView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 0),
            youtubePlayerView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: 0),
            youtubePlayerView.centerYAnchor.constraint(equalTo: view.centerYAnchor),
            youtubePlayerView.heightAnchor.constraint(equalTo: view.widthAnchor, multiplier: 9/16)
        ])

        youtubePlayerView.load(withVideoId: "eEqMwv362kM", playerVars: playerVars)
    }
}

I added this controller as third tab on the tab controller in the example app. With this code I can reproduce the issue again.

Is there something wrong in the way I use the youtube player view here ?

shusta-patreon commented 2 years ago

@marcelderkskarlmax @rcvrgs @jasonszheng I see this issue too, and think I partially narrowed it down -- the player maintains subtitles when going to fullscreen if the embedded player is not full width:

youtubePlayerView.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 10),
youtubePlayerView.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -10),
Embedded full-width to fullscreen has no subs Embedded partial-width to full screen has subs

I could conjecture that if the width doesn't change, the player doesn't know that it needs to re-apply the subtitles (?).

marcelderkskarlmax commented 2 years ago

Wow ! Thank you so much !

I would never have had the idea to try that out. Maybe I can constraint the video one pixel at each side to the negative screen space. So that there would be still no visible gap.