unity3d 安卓播放視頻替代視頻紋理

來源:互聯網
上載者:User

標籤:style   blog   class   code   java   c   

匯出apk,是不能用電影紋理的,所以我們只能用這個辦法

這個

            Handheld.PlayFullScreenMovie();

 或者這個函數
            iPhoneUtils.PlayMovie();

 

 void OnGUI()    {        if (GUI.Button(new Rect(Screen.width / 2 - 10, Screen.height / 2 - 10,  100,20), "(h)CancelOnTouch"))        {            Handheld.PlayFullScreenMovie("123.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);        }        if (GUI.Button(new Rect(Screen.width / 2 - 10, Screen.height / 2 + 10, 100, 20), "(h)Full"))        {            Handheld.PlayFullScreenMovie("123.mp4", Color.black, FullScreenMovieControlMode.Full);        }        if (GUI.Button(new Rect(Screen.width / 2 - 10, Screen.height / 2 + 30, 100, 20), "(h)Hidden"))        {            Handheld.PlayFullScreenMovie("123.mp4", Color.black, FullScreenMovieControlMode.Hidden);        }        if (GUI.Button(new Rect(Screen.width / 2 - 10, Screen.height / 2 + 50, 100, 20), "(h)Minimal"))        {            Handheld.PlayFullScreenMovie("123.mp4", Color.black, FullScreenMovieControlMode.Minimal);        }          }  
FullScreenMovieControlMode有四種模式,

1.視頻播放時觸控螢幕幕視頻關閉

2.視頻播放時彈出IOS進階控制項,控制視頻暫停播放 全屏等等。

3.視頻播放時無法停止,當其播放完一次後自動關閉

4.視頻播放時彈出IOS進階控制項,可控制播放進度。

 

四種模式

iPhoneUtils.PlayMovie();

也是一樣

 void OnGUI()    {        if (GUI.Button(new Rect(Screen.width / 2 - 110, Screen.height / 2 - 10, 100, 20), "(i)CancelOnTouch"))        {            iPhoneUtils.PlayMovie("123.mp4", Color.black, iPhoneMovieControlMode.CancelOnTouch, iPhoneMovieScalingMode.AspectFit);        }        if (GUI.Button(new Rect(Screen.width / 2 - 110, Screen.height / 2 + 10, 100, 20), "(i)Full"))        {            iPhoneUtils.PlayMovie("123.mp4", Color.black, iPhoneMovieControlMode.Full, iPhoneMovieScalingMode.AspectFit);        }        if (GUI.Button(new Rect(Screen.width / 2 - 110, Screen.height / 2 + 30, 100, 20), "(i)Hidden"))        {            iPhoneUtils.PlayMovie("123.mp4", Color.black, iPhoneMovieControlMode.Hidden, iPhoneMovieScalingMode.AspectFit);        }        if (GUI.Button(new Rect(Screen.width / 2 - 110, Screen.height / 2 + 50, 100, 20), "(i)Minimal"))        {            iPhoneUtils.PlayMovie("123.mp4", Color.black, iPhoneMovieControlMode.Minimal, iPhoneMovieScalingMode.AspectFit);        }    }  

 

iPhoneMovieControlMode的方法已經過時,可以換成FullScreenMovieControlMode

iPhoneMovieScalingMode就是調scale的模式,設為null就行。
照常理這樣就可以播放了,


但是又遇到了另一個問題
不播放視頻,一片漆黑,但是顯示著最終時間
這個就是手機解析度的問題,切記解析度(GAME面板中)一定要和手機設定的一樣,否則就不會播放


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.