-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.cs
More file actions
109 lines (91 loc) · 3.61 KB
/
temp.cs
File metadata and controls
109 lines (91 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
Partial Working solution with baseline videos
*/
// using System.Collections;
// using System.Collections.Generic;
// using System.IO;
// using UnityEngine;
// using UnityEngine.Networking;
// using UnityEngine.Video;
// public class VideoPlayerController : MonoBehaviour
// {
// public VideoPlayer videoPlayer1;
// public VideoPlayer videoPlayer2;
// public RenderTexture renderTexture1;
// public RenderTexture renderTexture2;
// public Material skyboxMaterial;
// public int segmentNumber = 1;
// public float switchTimeBeforeEnd = 0.9f; // Time in seconds before the video ends to switch
// private string videoDirectory;
// void Start()
// {
// videoDirectory = Path.Combine(Application.persistentDataPath, "Videos");
// videoPlayer1.targetTexture = renderTexture1;
// videoPlayer2.targetTexture = renderTexture2;
// // Ensure the skybox material uses the render texture of the currently active video player
// skyboxMaterial.mainTexture = renderTexture1;
// StartCoroutine(PlayNextVideo(videoPlayer1, renderTexture1));
// }
// private IEnumerator PlayNextVideo(VideoPlayer videoPlayer, RenderTexture renderTexture)
// {
// if (segmentNumber > 10)
// {
// Debug.Log("All videos played");
// yield break;
// }
// string filePath = Path.Combine(Application.persistentDataPath, "segment" + segmentNumber + ".mp4");
// Debug.Log($"Playing video: {filePath}");
// videoPlayer.url = filePath;
// videoPlayer.prepareCompleted += videoPrepared;
// videoPlayer.Prepare();
// }
// private void videoPrepared(VideoPlayer videoPlayer)
// {
// if(segmentNumber > 10)
// {
// Debug.Log("All videos played");
// return;
// }
// Debug.Log("Video prepared");
// Debug.Log("Playing video : "+ segmentNumber);
// if(videoPlayer == videoPlayer1) {
// skyboxMaterial.mainTexture = renderTexture1;
// }
// else {
// skyboxMaterial.mainTexture = renderTexture2;
// }
// videoPlayer.Play();
// videoPlayer.prepareCompleted -= videoPrepared;
// videoPlayer.loopPointReached += OnVideoEnded;
// // Schedule the preparation of the next segment a few milliseconds before the current one ends
// StartCoroutine(PrepareNextSegment(videoPlayer));
// }
// private IEnumerator PrepareNextSegment(VideoPlayer currentVideoPlayer)
// {
// yield return new WaitForSeconds((float)currentVideoPlayer.length - switchTimeBeforeEnd);
// segmentNumber++;
// if (segmentNumber > 10)
// {
// Debug.Log("All videos played");
// yield break;
// }
// string nextFilePath = Path.Combine(Application.persistentDataPath, "segment" + segmentNumber + ".mp4");
// if (currentVideoPlayer == videoPlayer1)
// {
// videoPlayer2.url = nextFilePath;
// videoPlayer2.prepareCompleted += videoPrepared;
// videoPlayer2.Prepare();
// }
// else
// {
// videoPlayer1.url = nextFilePath;
// videoPlayer1.prepareCompleted += videoPrepared;
// videoPlayer1.Prepare();
// }
// }
// private void OnVideoEnded(VideoPlayer videoPlayer)
// {
// Debug.Log("Video ended");
// videoPlayer.loopPointReached -= OnVideoEnded;
// }
// }