Unity在android环境下播放视频

话不多说,直接上代码:

Handheld.PlayFullScreenMovie(url, Color.black, FullScreenMovieControlMode.CancelOnInput);

url为字符串,如果视频存放在项目目录下,需要在Asset下创建一个StreamingAssets文件夹,将视频文件放在StreamingAssets下。url为视频文件名称即可。再贴一段代码解释最后一个参数的意义:

void OnGUI()
	{
		if (GUI.Button(new Rect(20, 10, 200, 250), "播放"))//触屏后会取消播放
		{
			Handheld.PlayFullScreenMovie(url, Color.black, FullScreenMovieControlMode.Full);
		}

		if (GUI.Button(new Rect(20, 290, 200, 200), "全屏播放"))
		{
			Handheld.PlayFullScreenMovie(url, Color.black, FullScreenMovieControlMode.Full);
		}

		if (GUI.Button(new Rect(20, 500, 200, 200), "隐藏按钮控制器"))//隐藏控制器
		{
			Handheld.PlayFullScreenMovie(url, Color.black, FullScreenMovieControlMode.Hidden);
		}

		if (GUI.Button(new Rect(200, 250, 200, 200), "迷你控制器"))
		{
			Handheld.PlayFullScreenMovie(url, Color.black, FullScreenMovieControlMode.Minimal);
		}

	}

 

你可能感兴趣的:(Unity)