{"id":1551,"date":"2022-05-25T13:55:13","date_gmt":"2022-05-25T05:55:13","guid":{"rendered":"https:\/\/104.es\/?p=1551"},"modified":"2022-05-25T13:55:13","modified_gmt":"2022-05-25T05:55:13","slug":"unity-videoplayer-example","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2022\/05\/25\/unity-videoplayer-example\/","title":{"rendered":"Unity VideoPlayer\u64cd\u4f5c\u7bc4\u4f8b"},"content":{"rendered":"\n<p>\u5728Unity\u4e0a\u900f\u904eUI\u4f86\u64cd\u4f5c\u5f71\u7247\u7684\u64ad\u653e\u9084\u7b97\u7c21\u55ae\uff0c\u5728\u9019\u500b\u4f8b\u5b50\u4e2d\uff0c\u6211\u5011\u9700\u8981VideoPlayer\u3001Render Texture\u3001Button\u4ee5\u53caRawImage\uff0c\u4ee5\u53ca\u5e7e\u500b\u8981\u64ad\u653e\u7684\u5f71\u7247\uff0c\u9996\u5148\uff0c\u8a2d\u5b9a\u7684\u7269\u4ef6\u968e\u5c64\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"254\" height=\"231\" src=\"http:\/\/104es.nkust.org\/wp-content\/uploads\/2022\/05\/image-16.png?w=254\" alt=\"\" class=\"wp-image-1554\" \/><\/figure>\n\n\n\n<p>\u76f4\u63a5\u4f86\u770b\u7a0b\u5f0f\u78bc\u7684\u90e8\u4efd\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using System.Collections;\nusing System.Collections.Generic;\nusing UnityEngine;\nusing UnityEngine.UI;\nusing UnityEngine.Video;\n\npublic class myvplayer : MonoBehaviour\n{\n    public VideoPlayer vp;\n    public VideoClip&#091;] clips;\n    private int index = 0;\n    void Start()\n    {\n        vp.clip = clips&#091;index];\n    }\n\n    public void NextVideo()\n    {\n        if (++index&gt;2) index = 0;\n        vp.clip = clips&#091;index];\n        vp.Stop();\n        vp.Play();\n    }\n\n    public void PrevVideo()\n    {\n        if(--index&lt;0) index = 2;\n        vp.clip = clips&#091;index];\n        vp.Stop();\n        vp.Play();\n    }\n    public void PlayVideo()\n    {\n        vp.Play();\n    }\n\n    public void StopVideo()\n    {\n        vp.Stop();\n    }\n\n    public void PauseVideo()\n    {\n        vp.Pause();\n    }\n}\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Unity\u4e0a\u900f\u904eUI\u4f86\u64cd\u4f5c\u5f71\u7247\u7684\u64ad\u653e\u9084\u7b97\u7c21\u55ae\uff0c\u5728\u9019\u500b\u4f8b\u5b50\u4e2d\uff0c\u6211\u5011\u9700\u8981VideoPlayer\u3001Render Texture\u3001Button\u4ee5\u53caRawImage\uff0c\u4ee5\u53ca\u5e7e\u500b\u8981\u64ad\u653e\u7684\u5f71\u7247<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[18],"tags":[66],"class_list":["post-1551","post","type-post","status-publish","format-standard","hentry","category-unity","tag-videoplayer"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/1551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/comments?post=1551"}],"version-history":[{"count":0,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/1551\/revisions"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=1551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=1551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=1551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}