视频播放--MovieTexture和VideoPlayer
来源:互联网 发布:coc五级龙数据 编辑:程序博客网 时间:2024/04/29 18:52
MovieTexture:
Movie Textures are animated Textures that are created from a video file. By placing a video file in your project’sAssets Folder, you can import the video to be used exactly as you would use a regularTexture.
Video files are imported via Apple QuickTime. Supported file types are what your QuickTime installation can play (usually.mov,.mpg,.mpeg, .mp4,.avi,.asf). On Windows, movie importing requires Quicktime to be installed. Download Quicktime fromApple Support Downloads.
电影纹理是从视频文件中创建的动画纹理。将视频文件导入到工程的资源文件夹下,就可以像使用普通纹理一样使用了。需要注意的是,视频文件要通过Apple QuickTime导入,所以电脑上要先安装这个软件。
获取到MovieTexture之后,只需将其设置到某一组件的Texture上,便可通过MovieTexture自带的函数比如Play,Pause,Stop等控制画面的显示,但要想播放声音,还需要在场景中添加AudioSource,像播放普通音频一样进行播放。
下例是在RawImage上播放视频,同时播放声音的示例:
using System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.UI;public class VideoPlayTest : MonoBehaviour { public MovieTexture movie; private AudioSource audio;// Use this for initializationvoid Start () { GetComponent<RawImage>().texture = movie; audio = GetComponent<AudioSource>(); movie.Play(); audio.Play();}// Update is called once per framevoid Update () { if (Input.GetKeyDown(KeyCode.Space)) { if (movie.isPlaying && audio.isPlaying) { movie.Pause(); audio.Pause(); } else { movie.Play(); audio.Play(); } } if (Input.GetKeyDown(KeyCode.UpArrow)) audio.volume +=0.1f; if(Input.GetKeyDown(KeyCode.DownArrow)) audio.volume -= 0.1f; }}
VideoPlayer
Use Unity’s video system to integrate video into your game. Video footage can add realism, save on rendering complexity, or help you integrate content available externally.
To use video in Unity, import Video Clips and configure them using the Video Player component. The system allows you to feed video footage directly into theTexture parameter of any component that has one. Unity then plays the Video on that Texture at run time.
Unity’s video features include the hardware-accelerated and software decoding ofVideo files, transparency support, multiple audio tracks, and network streaming.
Note: The Video Player component and Video Clip asset, introduced in Unity 5.6, supersede the earlierMovie Textures feature.
特征:Unity的视频功能包括硬件加速和视频文件的软件解码、透明支持、多音轨和网络流。
Video Player是Unity5.6之后新增加的,丰富了Unity播放频的功能,可轻松实现视频播放速度的控制,快进快退,视频透明度控制等。在使用时,将文件导入到工程中后,将其导入格式设置成Video Clip,就可以将其直接设置给Video Player组件的Video Clip属性(前提是Source属性选择为Video Clip方式)。当然,也可以设置Source为URL模式,通过给定具体的视频地址实现视频的播放。
CameraFarPlaneDraw video content behind a camera's scene.CameraNearPlaneDraw video content in front of a camera's scene.RenderTextureDraw video content into a RenderTexture.MaterialOverrideDraw the video content into a user-specified property of the current GameObject's material.APIOnlyDon't draw the video content anywhere, but still make it available via the VideoPlayer's texture property in the API.VideoPlayer的渲染模式有以上几种,选择不同的模式可以将视频渲染到不同的对象上,比如UI控件上、3D物体上,相机近平面和远平面上等。此外,将视频文件拖到不同的GameObject上,系统会自动设置相应的渲染模式。
相关博文:http://blog.csdn.net/dark00800/article/details/70160463点击打开链接
- 视频播放--MovieTexture和VideoPlayer
- Unity3d MovieTexture 实现视频播放
- videoPlayer 无法播放视频
- cocos2d-x播放视频(VideoPlayer)小记
- Cocos2d-3.2 VideoPlayer 视频播放梳理01
- Cocos2d-3.2 VideoPlayer 视频播放梳理02
- 利用TitleWindow和VideoPlayer组件轻松实现视频弹出播放效果
- (更新版)Android VideoPlayer 在滚动列表实现item视频播放(ListView控件和RecyclerView)
- cocos2d-x lua 播放视频,VideoPlayer在Android和IOS下的坑,
- 【Unity3d】使用MovieTexture和Image实现简单的播放器
- cocos2dx 3.3 视频播放的实现-VideoPlayer的使用
- cocos2dx3.3视频播放的实现VideoPlayer的使用
- cocos2dx 视频播放——VideoPlayer的使用
- cocos2dx3.3视频播放的实现VideoPlayer的使用
- unity5.6.0新版本使用videoplayer发布后视频不能播放
- 关于VideoPlayer以及使用VUforia播放视频的见解
- 关于Unity3D VideoPlayer播放视频中的声音的问题
- MovieTexture 影片纹理,预告片播放
- Linux编程学习之文件IO篇-lseek函数
- 1007. Maximum Subsequence Sum
- Java的循环部分
- 获取计算机网络相关信息
- windows下mysql配置文件my.ini的位置
- 视频播放--MovieTexture和VideoPlayer
- HK Missing Numbers
- 使用Python抓取我爱我家二手房数据
- PAT (Advanced Level) Practise 1053 Path of Equal Weight (30)
- C
- Qt常用类(2) —— QChar类
- D
- 徽章系列2:JitPack 的使用
- Radan 的Mrp导入加工清单功能