Unity3D浅析在Android和IOS平台上播放视频方法

方法1:

Handheld.PlayFullScreenMovie ("Splash.mp4",Color.white,FullScreenMovieControlMode.Hidden);

使用方法:

//Start
void Start()
{

  //播放CG
  StartCoroutine(PlayCG(PlayCGCallBack));

}
//播放CG
private IEnumerator PlayCG(System.Action callBack)
{
  //播放CG
  Handheld.PlayFullScreenMovie("CG.mp4", Color.black, FullScreenMovieControlMode.CancelOnInput);
  yield return new WaitForEndOfFrame();
  if (callBack != null) callBack();
}
//播放完毕回调
private void PlayCGCallBack()
{
  //播放完毕
}

方法2:

iPhoneUtils.PlayMovie("Splash.mp4", Color.black, iPhoneMovieControlMode.Hidden,iPhoneMovieScalingMode.AspectFit);

使用方法:

//Start
void Start()
{

  //播放CG
  StartCoroutine(PlayCG(PlayCGCallBack));

}
//播放CG
private IEnumerator PlayCG(System.Action callBack)
{
  //播放CG
  iPhoneUtils.PlayMovie("Splash.mp4", Color.black, iPhoneMovieControlMode.Hidden,iPhoneMovieScalingMode.AspectFit);
  yield return new WaitForEndOfFrame();
  if (callBack != null) callBack();
}
//播放完毕回调
private void PlayCGCallBack()
{
  //播放完毕
}

注:视频文件放在Assets\StreamingAssets文件夹下。

未经允许不得转载:第一Unity3D » Unity3D浅析在Android和IOS平台上播放视频方法

赞 (0)