How to play vimeo video on UIwebview not in fullscreen ios swift 2.0

please can someone help me how can I play Vimeo videos with a specific height and width on iOS swif 2.0 2.0 uiwebview. The problem is that it plays successfully, but in full screen mode. I need to play this video with a certain height and width. because my iPhone app layout has [header - body - footer]. I want to play Vimeo videos only on the body part where uiwebview is present. currently my application is working, but it only comes out in full screen mode. on the full-screen header and footer is invisible.

thanks.
here is my code

embedHTML value is specified in the iframe html tag

" let embedHTML = <iframe>src='http://player.vimeo.com/video/12345678?title=0&amp;byline=0&amp;portrait=0'width=\"100%\" height=\"100%\" frameborder=\"0\"</iframe> ";

let url: NSURL = NSURL(string: "http")! webView.allowsInlineMediaPlayback = true webView.loadHTMLString(embedHTML as String, baseURL:url ) self.view.addSubview(webView)

+4
source share
2 answers

In addition to

 webView.allowsInlineMediaPlayback = true 

Your video must have the webkit-playinginline attribute.

Below is the text from Apple docs:

"In order for a video to play inline, you must not only set this property in the view, but the video element in the HTML document must also include the webkit-playinginline attribute."

So, your video tag should look something like this: <video class = "poster =" "webkit-playinginline>

Since you want to play vimeo, you will need to see if it is possible to add this attribute, otherwise it seems impossible.

+3
source

In fast 2.2,

Along with the line: webView.allowsInlineMediaPlayback = true in viewdidload you need to include & playinline = 1 inside the iframe tag, as shown below:

// width = 100 height = 100 finalURL1 = MWuj4td1PQk

// src = " https://www.youtube.com " + "/ embed /" + finalURL1

enter the code: NSString = "";

0
source

All Articles