[Unity] PlayFullScreenMovie from PersistentDataPath (iOS + Android)



要點只有一個,就是存在 iOS 下的路徑要加上 “file://”
但是確認檔案存在與否時不可加,否則會判斷為找不到


private IEnumerator DownloadVideo( string url )
{
	var www = new WWW( url );
	while ( !www.isDone )
	{
		Debug.Log( "Progress: " + www.progress );
		yield return null;
	}

	File.WriteAllBytes( Application.persistentDataPath + "/video.mp4", www.bytes );
}

private void PlayVideo( string fileName )
{
	var path = Application.persistentDataPath + fileName;

	if ( !File.Exists( path ) )
	{
		return;
	}

#if UNITY_IOS
	path = "file://" + path;
#endif

	Handheld.PlayFullScreenMovie( path );
}




歡迎您留言與分享!(Welcome for comments or sharing!)

Related Post:

Tagged on: