I'm having an issue trying to autoplay my UIWebView.
Yes, I know there are tons of questions regarding it already.
Fist off, here's my simple code:
override func viewDidLoad()
{
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let youtubePlayer:UIWebView = UIWebView(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height))
youtubePlayer.loadRequest(NSURLRequest(URL: NSURL(string: "https://www.youtube.com/embed/EzNinU0g-Q0")!) )
self.view.addSubview(youtubePlayer)
}
Now here's what I found:
- How to autoplay a YouTube video in a UIWebView
- Youtube video autoplay inside UIWebview
- How to get YouTube autoplay to work in UIWebView?
I did as suggested with the following codes:
youtubePlayer.mediaPlaybackRequiresUserAction = false
youtubePlayer.allowsInlineMediaPlayback = true
That did nothing.
This solution works, however, it's not for embedded videos, which is what I'm using.
Therefore, is there no way to auto-play using the UIWebView?
Those questions were posted years ago, so I'm not sure how things have changed.
Can anyone suggest an alternative? Since I have a UITableView
set up to where, when the user selects a cell (video), it will show the UIWebView of the video.
However, I would like, if possible for the video to start playing immediately when the user selects a video instead of having to press play again to play it.
I have a similar layout design to apps like TubiMusic and Tubex, but those apps are able to autoplay videos while I can't figure out how to do the same.
Any help would be appreciated. Thanks