|
@@ -14,6 +14,7 @@ public class Mp4Item : BaseFilePrefabItem
|
|
|
public AVProVideoPlayer aVProVideoPlayer;
|
|
|
public override void Init(FileConfig fileConfig)
|
|
|
{
|
|
|
+ hideBtn.onClick.AddListener(() => { StartCoroutine(CloseVideo()); });
|
|
|
Debug.Log("Hjj "+ fileConfig.Url);
|
|
|
base.Init(fileConfig);
|
|
|
if (!string.IsNullOrEmpty(fileConfig.Url))
|
|
@@ -25,20 +26,37 @@ public class Mp4Item : BaseFilePrefabItem
|
|
|
url = "https://" + fileConfig.Url;
|
|
|
}
|
|
|
|
|
|
- LangChaoRommMinIo.Instance.getFile(MQTTManager.Instance.roomId, fileConfig.Bucket, fileConfig.ObjectName, (RoomFileData rfd) => {
|
|
|
-
|
|
|
- Debug.Log("rfd==>" + rfd.url);
|
|
|
- Debug.Log("rfd==>" + rfd.bytes.Length);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- StartCoroutine(SaveMp4(Application.persistentDataPath + "/" + fileConfig.FileName, rfd.bytes));
|
|
|
- });
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ LangChaoRommMinIo.Instance.getFile(MQTTManager.Instance.roomId, fileConfig.Bucket, fileConfig.ObjectName, (RoomFileData rfd) => {
|
|
|
+
|
|
|
+ Debug.Log("rfd==>" + rfd.url);
|
|
|
+ Debug.Log("rfd==>" + rfd.bytes.Length);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ StartCoroutine(SaveMp4(Application.persistentDataPath + "/" + fileConfig.UUid + Path.GetExtension(fileConfig.FileName), rfd.bytes));
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private IEnumerator CloseVideo()
|
|
|
+ {
|
|
|
+ transform.position += new Vector3(10000, 0, 0);
|
|
|
+ yield return !string.IsNullOrEmpty(aVProVideoPlayer.GetUrl());
|
|
|
+ if (RoomFile.Instance.FilePrefabConfigList.Contains(this.fileConfig))
|
|
|
+ {
|
|
|
+ RoomFile.Instance.FilePrefabConfigList.Remove(this.fileConfig);
|
|
|
+ }
|
|
|
+ this.gameObject.SetActive(false);
|
|
|
+ if (this.fileConfig != null)
|
|
|
+ {
|
|
|
+ RoomFile.HidefileChooseAction?.Invoke(this.fileConfig);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private IEnumerator SaveMp4(string path , byte[] bytes)
|
|
@@ -47,17 +65,24 @@ public class Mp4Item : BaseFilePrefabItem
|
|
|
FileInfo file = new FileInfo(path);
|
|
|
if (file.Exists)
|
|
|
{
|
|
|
- file.Delete();
|
|
|
+
|
|
|
+ yield return new WaitForSeconds(0.02f);
|
|
|
+ aVProVideoPlayer.SetUrl(path);
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Stream sw = File.Create(path);
|
|
|
+
|
|
|
+
|
|
|
+ sw.Write(bytes, 0, bytes.Length);
|
|
|
+
|
|
|
+ sw.Close();
|
|
|
+ sw.Dispose();
|
|
|
+ yield return new WaitForSeconds(0.02f);
|
|
|
+ aVProVideoPlayer.SetUrl(path);
|
|
|
}
|
|
|
- Stream sw = File.Create(path);
|
|
|
-
|
|
|
-
|
|
|
- sw.Write(bytes, 0, bytes.Length);
|
|
|
-
|
|
|
- sw.Close();
|
|
|
- sw.Dispose();
|
|
|
- yield return new WaitForSeconds(0.02f);
|
|
|
- aVProVideoPlayer.SetUrl(path);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
protected override void Start()
|