画面にUiWebViewを配置し、YouTubeにアクセスします。
動画を再生すると、フルスクリーンで再生されますが、WebViewの中だけで再生(インライン再生)することは可能でしょうか?
Safariではフルスクリーンではなく画面上で再生されたので、何か方法があるのかと思い質問しました。
開発環境
Xcode:9.1
iOS:11.1
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
回答1件
0
ベストアンサー
import UIKit class ViewController: UIViewController { @IBOutlet weak var webView: UIWebView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. let url = URL(string: "https://www.youtube.com/watch?v=jmqRuQGdhLs") let request = URLRequest(url: url!) webView.allowsInlineMediaPlayback = true webView.loadRequest(request) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }
allowsInlineMediaPlayback - UIWebView | Apple Developer Documentation
allowsInlineMediaPlayback
A Boolean value that determines whether HTML5 videos play inline or use the native full-screen controller.
Declaration
var allowsInlineMediaPlayback: [Bool](https://developer.apple.com/documentation/swift/bool) { get set }
Discussion
You must set this property to play inline video. Set this property to
true
to play videos inline. Set this property tofalse
to use the native full-screen controller. When adding a video element to a HTML document on the iPhone, you must also include theplaysinline
attribute.The default value for iPhone is
false
and the default value for iPad istrue
.
投稿2017/12/03 07:08
総合スコア1698
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/12/05 12:38