Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OnVideoFinish event to the VimeoPlayer #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Assets/Vimeo/Scripts/Player/VideoController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class VideoController : MonoBehaviour

public delegate void PlaybackAction(VideoController controller);
public event PlaybackAction OnVideoStart;
public event PlaybackAction OnVideoFinish;
public event PlaybackAction OnPause;
public event PlaybackAction OnPlay;
public event PlaybackAction OnFrameReady;
Expand Down Expand Up @@ -68,6 +69,7 @@ public void Setup()
videoPlayer.prepareCompleted += VideoPlayerStarted;
videoPlayer.seekCompleted += VideoSeekCompleted;
videoPlayer.frameReady += VideoFrameReady;
videoPlayer.loopPointReached += VideoPlayerFinished;

videoPlayer.isLooping = true;

Expand Down Expand Up @@ -236,6 +238,13 @@ private void VideoPlayerStarted(VideoPlayer source)
StartCoroutine("WaitForRenderTexture");
}

private void VideoPlayerFinished(VideoPlayer source)
{
if (OnVideoFinish != null) {
OnVideoFinish(this);
}
}

private void VideoSeekCompleted(VideoPlayer source)
{
isSeeking = false;
Expand Down
9 changes: 9 additions & 0 deletions Assets/Vimeo/Scripts/Player/VimeoPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class VimeoPlayer : PlayerSettings
public event VimeoEvent OnStart;
public event VimeoEvent OnVideoMetadataLoad;
public event VimeoEvent OnVideoStart;
public event VimeoEvent OnVideoFinish;
public event VimeoEvent OnPause;
public event VimeoEvent OnPlay;
public event VimeoEvent OnFrameReady;
Expand Down Expand Up @@ -113,6 +114,7 @@ private void SetupVideoController()
controller.videoScreenObject = videoScreen;

controller.OnVideoStart += VideoStarted;
controller.OnVideoFinish += VideoFinished;
controller.OnPlay += VideoPlay;
controller.OnPause += VideoPaused;
controller.OnFrameReady += VideoFrameReady;
Expand Down Expand Up @@ -334,6 +336,13 @@ private void VideoStarted(VideoController controller)
}
}

private void VideoFinished(VideoController controller)
{
if (OnVideoFinish != null) {
OnVideoFinish();
}
}

private void VideoPlay(VideoController controller)
{
if (OnPlay != null) {
Expand Down