Video ending issue

Get help using Construct 2

Post » Thu Sep 18, 2014 9:07 am

I am using a video object in my game which plays two different videos at different stages.

I detect when the first video being played is finished using the "video.has ended" property. This works fine and allows the player to move
to the next stage in the game.

Later on, another video is to be played and there's an issue. Despite changing the video source (video.Set video source to...) to another
mp4 file, the "video.has ended" property still seems to be set to True, meaning when I enter this part of my code, the program thinks the player
has already viewed the second video and it moves onto the next stage.

Do I need to use two different video objects (not convenient, as I call a function to play the video, as it does other things before executing
the video.play method) or is there any way other than just changing the video object's source to reset its "has ended" property to false?
B
10
S
3
Posts: 87
Reputation: 957

Post » Thu Sep 18, 2014 10:40 am

The video "has ended" is just a trigger, so its not something that you set to true or false in that regards. But every time a video is done playing it will trigger what is in the video "as ended" , so unless you use some other variable to indicate what video "ending" you want your program to react to, it will react the same way to whether its the first video or the second video that is done playing.

So you could make a counter that every time a video "has ended" you add one and as a sub event in the video "has ended" you check to see what this value is. And then you make the program do what it needs to do here.

So first time when video 1 have played.

Video_counter = 1

IF Video_counter = 1 switch to map 2

Then you play video 2 and add one more

Video_counter = 2

etc etc.

Not 100% sure, but I think the Video "has ended" was actually intended to have the little green arrow, like "On created" "On destroyed" and so on, but might be a minor bug maybe.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Sep 18, 2014 10:46 am

Hi Nimos100,

Thank you for your feedback, but I'm not sure my issue was clear.

I am not trying to set the "has ended" property, but using it to detect when the player has finished viewing a video:

Video Has ended Function Call HideVideoDecor()

Basically, I have the video playing in a small TV graphic element which I want to hide once the video has finished playing. I also set
a variable "SeenFilm" to 1, which I test later in my code to continue the game.

This works fine in the first group of code in which it is used (it does detect the when the video ends), but then later, despite having
set the video to a new source file, trying to read the Has ended property still seems to results in it returning a "True". Basically, why isn't
this property reset to False when a new video file is selected for a given video object?
B
10
S
3
Posts: 87
Reputation: 957

Post » Thu Sep 18, 2014 11:12 am

In that case I would destroy the video element at the start of layout, and create it whenever you need it. Which I do with all elements for that simple reason that you dont have things in the game that are not used, and to remove rogue objects that can all of sudden screw things up if you are not careful.

So when the player trigger the TV and start playing the video you create the video object where it needs to be:

Create video
Video.set position = <X>, <Y>
Video.source = "Video1"
Video.Play
Seen_video = 1


Video.hasEnded
Video.Destroy

Subevent in video has ended:
If Seen_video = 1

Actions
Set Seen_video = 0 Then it will not trigger again
Go_to_map 2

Another subevent in video has ended:
If Seen_video = 2

Actions
Set Seen_video = 0 Then it will not trigger again
Go_to_map 3

This works fine in the first group of code in which it is used (it does detect the when the video ends), but then later, despite having
set the video to a new source file, trying to read the Has ended property still seems to results in it returning a "True".


You can check this really easy, if you in start of layout start video 1 then you make a video has ended and in here you tell it to play another video or the same video doesn't matter. And if it keeps playing you know that it works as it should. You ofc just have to make sure that your videos are not set to loop, which they shouldn't by default.

Basically, why isn't this property reset to False when a new video file is selected for a given video object?

Because its not a property that can be set, it is a trigger. It would be like wanting to set "On created" to true or false, its not how it works, it triggers every time a video has ended, and also why I think it was meant to have that little green arrow. It doesn't care which video file is selected, it triggers whenever that Video element is done playing a video.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Sep 18, 2014 6:18 pm

Have tried destroying the video object and creating a new instance and it now works. Thank you Nimos100
B
10
S
3
Posts: 87
Reputation: 957


Return to How do I....?

Who is online

Users browsing this forum: uzumiapps and 28 guests