\u83b7\u53d6apk\u7b7e\u540d<\/a>http:\/\/example.com\/video.mp4″];<\/p>\nAVPlayer *player = [AVPlayer playerWithURL:url];<\/p>\n
playerViewController.player = player;<\/p>\n
\/\/\u5c06AVPlayerViewController\u6dfb\u52a0\u5230\u89c6\u56fe\u63a7\u5236\u5668\u4e2d<\/p>\n
[self addChildViewController:playerViewController];<\/p>\n
[self.view addSubview:playerViewController.view];<\/p>\n
“`<\/p>\n
2. \u6dfb\u52a0\u753b\u4e2d\u753b\u529f\u80fd<\/p>\n
\u4e3a\u4e86\u6dfb\u52a0\u753b\u4e2d\u753b\u529f\u80fd\uff0c\u6211\u4eec\u9700\u8981\u5c06AVPlayerViewController\u7684delegate\u5c5e\u6027\u8bbe\u7f6e\u4e3a\u5f53\u524d\u89c6\u56fe\u63a7\u5236\u5668\uff0c\u5e76\u5b9e\u73b0AVPlayerViewControllerDelegate\u534f\u8bae\u4e2d\u7684pictureInPictureButtonHandler\u65b9\u6cd5\u3002<\/p>\n
“`<\/p>\n
\/\/\u8bbe\u7f6eAVPlayerViewController\u7684delegate\u5c5e\u6027<\/p>\n
playerViewController.delegate = self;<\/p>\n
\/\/\u5b9e\u73b0AVPlayerViewControllerDelegate\u534f\u8bae\u4e2d\u7684pictureInPictureButtonHandler\u65b9\u6cd5<\/p>\n
– (void)playerViewController:(AVPlayerViewController *)playerViewController<\/p>\n
pictureInPictureButtonHandler:(AVPictureInPictureController *)pictureInPictureController {<\/p>\n
if (pictureInPictureController.pictureInPictureActive) {<\/p>\n
\/\/\u6062\u590d\u89c6\u9891\u64ad\u653e\u5668\u7a97\u53e3\u5230\u539f\u6765\u7684\u5927\u5c0f\u548c\u4f4d\u7f6e<\/p>\n
[pictureInPictureController stopPictureInPicture];<\/p>\n
} else {<\/p>\n
\/\/\u5f00\u59cb\u753b\u4e2d\u753b<\/p>\n
[pictureInPictureController startPictureInPicture];<\/p>\n
}<\/p>\n
}<\/p>\n
“`<\/p>\n
3. \u5904\u7406\u753b\u4e2d\u753b\u72b6\u6001\u53d8\u5316<\/p>\n
\u5f53\u753b\u4e2d\u753b\u72b6\u6001\u53d1\u751f\u53d8\u5316\u65f6\uff0cAVPlayerViewController\u4f1a\u8c03\u7528\u5176delegate\u7684\u65b9\u6cd5\uff0c\u6211\u4eec\u9700\u8981\u5728\u8be5\u65b9\u6cd5\u4e2d\u66f4\u65b0\u89c6\u56fe\u63a7\u5236\u5668\u7684UI\u3002<\/p>\n
“`<\/p>\n
\/\/\u5b9e\u73b0AVPlayerViewControllerDelegate\u534f\u8bae\u4e2d\u7684playerViewController:willBeginPictureInPictureWithAnimator:\u65b9\u6cd5<\/p>\n
– (void)playerViewController:(AVPlayerViewController *)playerViewController<\/p>\n
willBeginPictureInPictureWithAnimator:(id)animator {<\/p>\n
\/\/\u66f4\u65b0UI<\/p>\n
\/\/\u5c06\u89c6\u9891\u64ad\u653e\u5668\u7a97\u53e3\u7f29\u5c0f\u5e76\u79fb\u52a8\u5230\u5c4f\u5e55\u7684\u67d0\u4e2a\u89d2\u843d<\/p>\n
}<\/p>\n
\/\/\u5b9e\u73b0AVPlayerViewControllerDelegate\u534f\u8bae\u4e2d\u7684playerViewController:didEndPictureInPictureWithAnimator:\u65b9\u6cd5<\/p>\n
– (void)playerViewController:(AVPlayerViewController *)playerViewController<\/p>\n
didEndPictureInPictureWithAnimator:(id)animator {<\/p>\n
\/\/\u66f4\u65b0UI<\/p>\n
\/\/\u5c06\u89c6\u9891\u64ad\u653e\u5668\u7a97\u53e3\u6062\u590d\u5230\u539f\u6765\u7684\u5927\u5c0f\u548c\u4f4d\u7f6e<\/p>\n
}<\/p>\n
“`<\/p>\n
\u4e09\u3001\u603b\u7ed3<\/p>\n
\u901a\u8fc7AVPlayerViewController\u548cAVPictureInPictureController\u4e24\u4e2a\u7c7b\uff0c\u6211\u4eec\u53ef\u4ee5\u5f88\u5bb9\u6613\u5730\u5b9e\u73b0iOS\u753b\u4e2d\u753b\u529f\u80fd\u3002\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u521b\u5efaAVPlayerViewController\u5bf9\u8c61\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u89c6\u56fe\u63a7\u5236\u5668\u4e2d\uff1b\u5c06AVPlayerViewController\u7684delegate\u5c5e\u6027\u8bbe\u7f6e\u4e3a\u5f53\u524d\u89c6\u56fe\u63a7\u5236\u5668\uff0c\u5e76\u5b9e\u73b0AVPlayerViewC<\/p>\n
<img src="https:\/\/i.cdn.yimenapp.com\/2023-04\/03\/17\/18721048806.jpgontrollerDelegate\u534f\u8bae\u4e2d\u7684pictureInPicturcordova\u751f\u6210ios\u9879\u76ee<\/a>eButtonHandler\u65b9\u6cd5\uff1b\u5904\u7406\u753b\u4e2d\u753b\u72b6\u6001\u53d8\u5316\uff0c\u66f4\u65b0\u89c6\u56fe\u63a7\u5236\u5668\u7684UI\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"iOS\u753b\u4e2d\u753b\u529f\u80fd\u662fiOS9\u4e2d\u65b0\u589e\u7684\u529f\u80fd\uff0c\u5b83\u53ef\u4ee5\u8ba9\u7528\u6237\u5728\u4f7f\u7528\u67d0\u4e9b\u5e94\u7528\u7a0b\u5e8f\u65f6\uff0c\u5c06\u89c6\u9891\u64ad\u653e\u5668\u7a97\u53e3\u7f29\u5c0f\u5e76\u79fb\u52a8\u5230\u5c4f\u5e55\u7684\u67d0\u4e2a\u89d2\u843d\uff0c\u7ee7\u7eed\u89c2\u770b\u89c6\u9891\u5185\u5bb9\u3002\u672c\u6587\u5c06\u4ecb\u7ecdiOS\u753b\u4e2d\u753b\u7684\u539f\u7406\u548c\u5f00\u53d1\u65b9\u6cd5\u3002\u4e00\u3001\u539f\u7406iOS\u753b\u4e2d\u753b\u529f<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2741,2740,593,2739,1520],"class_list":["post-1248","post","type-post","status-publish","format-standard","hentry","category-zuoapp","tag-android-","tag-app","tag-593","tag-2739","tag-1520"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/1248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/comments?post=1248"}],"version-history":[{"count":0,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/posts\/1248\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/media?parent=1248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/categories?post=1248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.com\/zhidian\/wp-json\/wp\/v2\/tags?post=1248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}