Skip to content
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

Sometimes only sound is played. Is video played under other views? #175

Open
rmvz3 opened this issue Jan 8, 2019 · 1 comment
Open

Sometimes only sound is played. Is video played under other views? #175

rmvz3 opened this issue Jan 8, 2019 · 1 comment

Comments

@rmvz3
Copy link

rmvz3 commented Jan 8, 2019

Hi there.

I've been struggling with this for a few days now. I'm playing Youtube videos in full screen but, randomly, some videos are just playing the sound with no image (not a black screen either). I think what happens is that they are playing in the background. This happens in all versions and devices.

I'm creating a view of the video with the size of the screen but, in fact, I don't add it to the view since it is always shown in full screen and the library really seems to create another view on its own to play in full screen and doesn't use the one I created. Anyway, when I add the video window to the view it keeps happens the same.

This is the code I use to configure my video:

                self.viewVideo = YouTubePlayerView(frame: (UIApplication.shared.delegate as! AppDelegate).window!.bounds)
                self.viewVideo.delegate = self

                self.viewVideo.playerVars =  [
                    "playsinline":"0" as AnyObject,
                    "controls":"1" as AnyObject,
                    "fs":"1" as AnyObject,
                    "iv_load_policy":"3" as AnyObject,
                    "modestbranding":"1" as AnyObject,
                    "rel":"0" as AnyObject,
                    "showinfo":"0" as AnyObject
                ]

                if button.url.count == 11
                {
                    self.viewVideo.loadVideoID(button.url)
                }
                else if let videoURL = URL(string: button.url)
                {
                    self.viewVideo.loadVideoURL(videoURL)
                }

On "playerReady" delegate method, I only have a "self.viewVideo.play()"

I've tried to "catch" the player subview on playerReady method to bring it to front but I can't identify the "real" one (I guess is a UIWebView)

Is anybody having the same issue?

@rmvz3 rmvz3 changed the title Video is randomly played under other views Sometimes only sound is played. Video is played under other views? Jan 8, 2019
@rmvz3 rmvz3 changed the title Sometimes only sound is played. Video is played under other views? Sometimes only sound is played. Is video played under other views? Jan 8, 2019
@sorinmiroiu97
Copy link

I've also had this issue in our app. Sometimes we could see the video and sometimes not. What I can suggest you to do is to add your youtubeView to your view hierarchy and anchor it there (meaning: use autolayout and drop the frame approach). That's what solved our issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants