Mobile side
On the mobile side, Unity does not provide Movietexture,avpro QuickTime nor can it be used, its most basic display scheme using the Playfullscreenmovie () function for full-screen playback, according to its official website interpretation, mainly has the following aspects:
(1) The video stream is obtained directly from the device memory, so the file can only be provided separately, and the video file is placed in the Streamingassets folder.
(2) In video playback, unity will stop, unity automatically resumes after playback, and the color in the screen will change to the background color of the player and resume after playback.
(3) in iOS, the inside is actually a method of calling MPMoviePlayerController
(4) Formats to support:. mov,. mp4,. MPV, and. 3GP, h.264,mpeg-4 Part 2 video
Handheld.playfullscreenmovie ("Starwars.mp4", Color.Black, Fullscreenmoviecontrolmode.canceloninput);
Ernest, two sentences more, or decisive third-party plug-ins, Mobile movie texture for Android is a very good thing, the use of open source video codec library Theora video decoding, and then through unity texture implementation of the display. To display the effect for multiple videos:
Some questions in the application:
(1) because the video codec library uses Theora, it can only support OGG, OGV format video and audio, if you want to use other formats you need to convert, you can Theora Converter. NET tool for conversion.
(2) The video seek function is not very accurate, although it can be used
(3) Multi-video playback problem, if you want to how many video playback at the same time, need to understand the implementation of internal code, modified can be used. Another problem with multi-video playback is the efficiency problem, if it is n video, there may be n a background thread in the decoding operation, the corresponding will also have n render pipeline to render, I RK3188 on the three different video playback, there will be a lag. The key code for the middle understanding of multi-video playback is below, the Texture2d.createexternaltexture function obtains the map resource from the video, Settextures () to draw, and if multiple videos are used, multiple materials (that is, multiple render pipelines) are required.
private void Allocatetexures () {m_channeltextures[0] = Texture2d.createexternaltexture (m_ystrid E, 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); }
Http://www.cnblogs.com/zsb517/p/4060814.html
Play video files on the mobile side