Collapse the parent view of YTPlayerView when picture in Picture is enabled · Issue #516 · youtube/youtube-ios-player-helper · GitHub | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Collapse the parent view of YTPlayerView when picture in Picture is enabled #516

Open
@syedabdulsamad

Description

@syedabdulsamad

Hi,

I want to navigate to different screens within my app when the video is in Picture in Picture (PIP) mode.
Here is my Code below

import UIKit
import YouTubeiOSPlayerHelper

class RQTarjmatulClassViewController: UIViewController {
    
    @IBOutlet var playerView: YTPlayerView!
    private var videoLink: String = ""
    private var startSecond : Int = 0
    
    
    internal static func instantiate(with videoLink: String, startSecond: Int) -> UIViewController? {
        
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let vc = storyboard.instantiateViewController(withIdentifier: "RQTarjmatulClassViewController") as? RQTarjmatulClassViewController
        vc?.videoLink = videoLink
        vc?.startSecond = startSecond
        return vc
    }


override func viewDidLoad() {
        super.viewDidLoad()
        playerView.delegate = self
        playerView.load(withVideoId: videoLink,  playerVars: ["playsinline": 1])
        
        let rightBarButton = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(dismissSettings))
        rightBarButton.setTitleTextAttributes([NSAttributedString.Key.font: UIFont.fontfor(.englishNormal, weight: .semiBold, style: .title3)], for: .normal)
        
        navigationItem.rightBarButtonItem = rightBarButton
}

@objc private func dismissSettings() {
        self.dismiss(animated: true, completion: .none)
    }
}

extension RQTarjmatulClassViewController : YTPlayerViewDelegate {
    func playerViewDidBecomeReady(_ playerView: YTPlayerView) {
        playerView.seek(toSeconds: Float(startSecond), allowSeekAhead: true)
        playerView.playVideo()
    }
}

when dismissSettings is called then the pip is also ended instead. dismissSettings dismisses the parent view controller where YTPlayerView is hosted but how can I keep the YTPlayerView in pip mode even when the parent view is dismissed or how the parent view can be collapsed or revived when coming in and out of the PIP?

Another thing is that the app has no control over PIP. The view automatically adds the PIP button when in fullscreen and handles all the PIP-related things. So any insight on this will be good as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      TMZ Celebrity News – Breaking Stories, Videos & Gossip

      Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

      Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

      🎥 Watch TMZ Live

      TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.