Sagar Aher
Sagar Aher

Reputation: 81

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

please any one can help me , how can i play Vimeo video with specific height and width on uiwebview iOS swift 2.0 . the problem is that it play successfully but in fullscreen mode . i have to play this video with specific height and width . because my iPhone app layout has [ header - body - footer ] . i want to play Vimeo video only on body portion where uiwebview present . currently my app work but issue only on fullscreen . on full-screen header and footer is invisible .

thanks.
here is my code

the embedHTML value is in html iframe 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)

Upvotes: 4

Views: 3811

Answers (2)

Ammo
Ammo

Reputation: 580

In addition to

webView.allowsInlineMediaPlayback = true

your video needs to have a webkit-playsinline attribute.

Below text is from Apple docs:

"In order for video to play inline, not only does this property need to be set on the view, but the video element in the HTML document must also include the webkit-playsinline attribute."

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

Since you want to play vimeo, you would need to see if there is possiblity to add that attribute, else it looks impossible.

Upvotes: 4

Meera Raveendran
Meera Raveendran

Reputation: 36

In swift 2.2,

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

//width = 100 height = 100 finalURL1= MWuj4td1PQk

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

let code:NSString = "";

Upvotes: 0

Related Questions