Skip to content

Commit 10ee03a

Browse files
committed
Merge branch 'dev' into Video
2 parents ce3fa02 + b28b9c8 commit 10ee03a

File tree

8 files changed

+1141
-43
lines changed

8 files changed

+1141
-43
lines changed

Demo/API_V2/Assets/API/APISO.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ MonoBehaviour:
1919
- {fileID: 11400000, guid: 9977a581037b84833a32b508e00eb1a2, type: 2}
2020
- {fileID: 11400000, guid: 56f316e0e10ba419bbf19bd7a68bfc4c, type: 2}
2121
- {fileID: 11400000, guid: 6f0972f5fdc56c543b23c9873d760bf5, type: 2}
22-
- {fileID: 11400000, guid: a461b8cd70d9e4e23ad1cc953bec31e9, type: 2}
2322
- {fileID: 11400000, guid: 7ef06699cee7846b7823e4cc421418eb, type: 2}
23+
- {fileID: 11400000, guid: a461b8cd70d9e4e23ad1cc953bec31e9, type: 2}
2424
- {fileID: 11400000, guid: 55de20d536f8c4689bbd80553d87fe46, type: 2}
2525
- {fileID: 11400000, guid: f2c56d751bb7c4c398db7c1db352517d, type: 2}
2626
- {fileID: 11400000, guid: b4a6196f623dd4435a4f3bd70af92d06, type: 2}

Demo/API_V2/Assets/API/Facility/FacilitySO.asset

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ MonoBehaviour:
1515
categoryName: "\u8BBE\u5907"
1616
categorySprite: {fileID: 21300000, guid: 53dd2b1922e5142ec8a53037f362fc56, type: 3}
1717
entryList:
18-
- {fileID: 11400000, guid: bbbc9b983d6d34ad3bac2921509f612f, type: 2}
19-
- {fileID: 11400000, guid: c17ae0ce755f04419b700825b20fd386, type: 2}
2018
- {fileID: 11400000, guid: a24af43ae51914d26b0bf637c283dab2, type: 2}
2119
- {fileID: 11400000, guid: 4eba2c9f2f2064e4081be74302ca4c33, type: 2}
20+
- {fileID: 11400000, guid: bbbc9b983d6d34ad3bac2921509f612f, type: 2}
21+
- {fileID: 11400000, guid: c17ae0ce755f04419b700825b20fd386, type: 2}
2222
- {fileID: 11400000, guid: ac09abff5d8bc48bbabd08bde820b58b, type: 2}
2323
- {fileID: 11400000, guid: 3bf339b994c544db3860ddf0a0dc8e20, type: 2}
2424
- {fileID: 11400000, guid: e92d94924be504167a342e42e1162f21, type: 2}

Demo/API_V2/Assets/API/FileSystem/FileSystemSO.asset

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ MonoBehaviour:
2424
- {fileID: 11400000, guid: 65ab1b01a722b4542a14fcf9decca3de, type: 2}
2525
- {fileID: 11400000, guid: 19b80cb144f0c4ea28a4ddca7a2c2f09, type: 2}
2626
- {fileID: 11400000, guid: 0aa5d76237c844275add1612c47bddaa, type: 2}
27-
- {fileID: 11400000, guid: 73c05fc1ffae94ec1b69a00ee261d529, type: 2}
2827
- {fileID: 11400000, guid: 65a826f5f949544d8990e673231bb80f, type: 2}
28+
- {fileID: 11400000, guid: 73c05fc1ffae94ec1b69a00ee261d529, type: 2}
2929
- {fileID: 11400000, guid: 3a901e80b59ad4aafbe373ee6a8df2d8, type: 2}
3030
- {fileID: 11400000, guid: e7ea0be62dc6543b0a8dc629489c5e7e, type: 2}
3131
categoryOrder: 11
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using UnityEngine;
2+
using UnityEngine.UI;
3+
using UnityEngine.Video;
4+
using WeChatWASM;
5+
6+
public class VideoController : MonoBehaviour
7+
{
8+
public VideoPlayer videoPlayer; // 关联 VideoPlayer 组件
9+
public Button playButton; // 关联播放按钮
10+
public Button pauseButton; // 关联暂停按钮
11+
public string[] videoUrls; // 视频路径
12+
private int currentVideoIndex = 0;
13+
14+
void Start()
15+
{
16+
// 设置视频路径
17+
videoPlayer.url = videoUrls[currentVideoIndex];
18+
19+
// 添加按钮点击事件
20+
playButton.onClick.AddListener(PlayVideo);
21+
pauseButton.onClick.AddListener(PauseVideo);
22+
23+
// 添加视频播放完成事件
24+
videoPlayer.loopPointReached += OnVideoEnd;
25+
26+
}
27+
28+
void PlayVideo()
29+
{
30+
if (videoPlayer.isPaused)
31+
{
32+
videoPlayer.Play(); // 如果视频已暂停,则继续播放
33+
}
34+
}
35+
36+
void PauseVideo()
37+
{
38+
if (videoPlayer.isPlaying)
39+
{
40+
videoPlayer.Pause(); // 暂停视频
41+
}
42+
}
43+
44+
// 视频播放完成时调用的方法
45+
void OnVideoEnd(VideoPlayer vp)
46+
{
47+
Debug.Log("视频播放完成");
48+
49+
// 增加当前视频索引
50+
currentVideoIndex++;
51+
52+
// 检查是否还有下一个视频
53+
if (currentVideoIndex < videoUrls.Length)
54+
{
55+
videoPlayer.url = videoUrls[currentVideoIndex]; // 设置下一个视频的 URL
56+
}
57+
else
58+
{
59+
currentVideoIndex = 0; // 如果没有下一个视频,重置索引(可选)
60+
}
61+
videoPlayer.url = videoUrls[currentVideoIndex];
62+
videoPlayer.Play(); // 播放下一个视频
63+
}
64+
}

Demo/API_V2/Assets/API/Video/VideoController.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using UnityEngine;
2+
using UnityEngine.UI;
3+
using UnityEngine.Video;
4+
5+
public class VideoPlayerSliderController : MonoBehaviour
6+
{
7+
public VideoPlayer m_player;
8+
public Slider m_slider;
9+
public bool m_bMouseUp = true;
10+
void Start()
11+
{
12+
m_slider.onValueChanged.AddListener((float value) =>
13+
{
14+
if (!m_bMouseUp)
15+
{
16+
SliderEvent(value);
17+
}
18+
});
19+
}
20+
21+
// 如果启用 MonoBehaviour,则每个固定帧速率的帧都将调用此函数
22+
private void FixedUpdate()
23+
{
24+
if (m_bMouseUp)
25+
{
26+
m_slider.value = m_player.frame / (m_player.frameCount * 1.0f);
27+
}
28+
}
29+
30+
public void PointerDown()
31+
{
32+
m_player.Pause();
33+
m_bMouseUp = false;
34+
}
35+
36+
public void PointerUp()
37+
{
38+
m_player.Play();
39+
m_bMouseUp = true;
40+
}
41+
42+
public void SliderEvent(float value)
43+
{
44+
m_player.frame = long.Parse((value * m_player.frameCount).ToString("0."));
45+
}
46+
}

Demo/API_V2/Assets/API/Video/VideoPlayerSliderController.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)