标签:android blog http io ar color os 使用 sp
http://www.cnblogs.com/zsb517/p/4060814.html
Pause | Pauses playing the movie. |
Play | Starts playing the movie. |
Stop | Stops playing the movie, and rewinds it to the beginning. |
audioClip | Returns the AudioClip belonging to the MovieTexture. |
duration | The time, in seconds, that the movie takes to play back completely. |
isPlaying | Returns whether the movie is playing or not. |
isReadyToPlay | If the movie is downloading from a web site, this returns if enough data has been downloaded so playback should be able to start without interruptions. |
loop | Set this to true to make the movie loop. |
1 renderer.material.mainTexture = movie; //设置材质 2 3 movie.loop = true; //循环播放 4 movie.Play(); //播放 5 movie.Pause(); //暂停 6 movie.Stop();
在移动端,unity并不提供MovieTexture,AVPro QuickTime也用不了,其最基本的显示方案使用通过PlayFullScreenMovie()函数进行全屏播放,根据其官网解释,主要有以下方面:
(1)视频流直接从设备存储器中获得,所以文件只能是单独提供,视频文件放置在StreamingAssets 文件夹中
(2) 视频播放过陈中,Unity将会停止;播放结束后unity自动恢复;播放过程中屏幕中的颜色会变为播放器的背景颜色,播放之后恢复。
(3)在IOS中,内部实际上是调用MPMoviePlayerController的方法
(4)能够支持的格式: .mov, .mp4, .mpv, and .3gp ,H.264,MPEG-4 Part 2 video
Handheld.PlayFullScreenMovie ("StarWars.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
话不投机,两句多,还是果断第三方插件,Mobile movie texture for android 就是很不错的东西,利用开源视频编解码库Theora进行视频解码,然后通过Unity Texture实现显示。下图为多视频显示效果:
应用中的一些问题:
(1)因为视频编解码库是使用Theora ,所以只能支持OGG、OGV格式的视频和音频,如果要使用其他格式则需要转换一下,可以Theora Converter .NET工具进行转换。
(2)视频seek功能不是很精确,虽然能用
(3)多视频播放问题,如果想要多少视频同时播放,需要理解内部代码的实现,修改后可以凑合着使用。多视频播放的另外一个问题是效率问题,如果是N个视频,可能就会有N个后台线程在进行解码操作,相应的也会有N个渲染管道进行渲染,我在RK3188上进行三个不同视频的播放,就会有卡顿。多视频播放中间理解的关键代码在下面,Texture2D.CreateExternalTexture 函数从视频中获得贴图资源,SetTextures()进行绘制,如果使用多个视频,需要多个材质(也就是多个渲染管道)。
private void AllocateTexures() { m_ChannelTextures[0] = Texture2D.CreateExternalTexture(m_yStride, m_yHeight, TextureFormat.BGRA32, false, false, GetNativeYHandle(m_nativeContext)); m_ChannelTextures[1] = Texture2D.CreateExternalTexture(m_uvStride, m_uvHeight, TextureFormat.RGBA32, false, false, GetNativeCrHandle(m_nativeContext)); m_ChannelTextures[2] = Texture2D.CreateExternalTexture(m_uvStride, m_uvHeight, TextureFormat.RGBA32, false, false, GetNativeCbHandle(m_nativeContext)); if (m_movieMaterials != null) { for (int i = 0; i < m_movieMaterials.Length; ++i) { var mat = m_movieMaterials[i]; if (mat != null) { SetTextures(mat); } } } } public void SetTextures(Material material) { material.SetTexture("_YTex", m_ChannelTextures[0]); material.SetTexture("_CrTex", m_ChannelTextures[1]); material.SetTexture("_CbTex", m_ChannelTextures[2]); material.SetTextureScale("_YTex", m_uvYScale); material.SetTextureOffset("_YTex", m_uvYOffset); material.SetTextureScale("_CbTex", m_uvCrCbScale); material.SetTextureOffset("_CbTex", m_uvCrCbOffset); }
转载 请注明:细雨淅淅
标签:android blog http io ar color os 使用 sp
原文地址:http://www.cnblogs.com/123ing/p/4114390.html