Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (VoroneTZ, monk12, Quad), 829 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Video control #468771
10/18/17 07:14
10/18/17 07:14
Joined: Nov 2016
Posts: 31
middleagechinese Offline OP
Newbie
middleagechinese  Offline OP
Newbie

Joined: Nov 2016
Posts: 31
I made some mistake here, and I wasn't able to find it yet.
But after the first video plays, the loop, that is suppose to play afterwards does not play.
Can anybody give me an hint why that is?

Code:
function handle_videos()
{
	while(1)
	{
		if(intro_played == 1)
		{
			intro_played = 0;
			var handle_intro_played = media_play("demo.ogg",NULL,100); 
			while(handle_intro_played){wait(1);}
			media_stop(handle_intro_played);
			wait(1);
			start_loop1 = 1;
		}
		if(start_loop1 == 1)
		{
			start_loop1 = 0;
			var handle_start_loop1 = media_loop("demo.ogg",NULL,100); 
		}
		wait(1);
	}	
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

function start_into()
{
	intro_played = 1;
	start_loop1 = 0;
	start_choice1 = 0;
	start_choice2 = 0;
	intro_room1 = 0;
	room1_loop1 = 0;
	room1_choice1 = 0;
	room1_choice2 = 0;
	room1_action_loop = 0;
	room1_action_loop_fail = 0;
	room1_action_loop_win = 0;
	room1_exit = 0;
	intro_room2 = 0;
	room2_loop2 = 0;
	room2_choice1 = 0;
	room2_choice2 = 0;
	room2_action_loop = 0;
	room2_action_loop_fail = 0;
	room2_action_loop_win = 0;
	room2_exit = 0;
	intro_room3 = 0;
	room3_loop1 = 0;
	room3_choice1 = 0;
	room3_choice2 = 0;
	room3_action_loop = 0;
	room3_action_loop_fail = 0;
	room3_action_loop_win = 0;
	room3_exit = 0;
	intro_room4 = 0;
	room4_loop1 = 0;
	room4_choice1 = 0;
	room4_choice2 = 0;
	room4_action_loop = 0;
	room4_action_loop_fail = 0;
	room4_action_loop_win = 0;
	room4_exit = 0;
	intro_room1 = 0;
	room5_loop1 = 0;
	room5_choice1 = 0;
	room5_choice2 = 0;
	room5_choice3 = 0;
	room5_choice4 = 0;
	room5_choice5 = 0;
	room5_action_loop1 = 0;
	room5_action_loop1_fail = 0;
	room5_action_loop2 = 0;
	room5_action_loop2_fail = 0;
	room5_action_loop3 = 0;
	room5_action_loop3_fail = 0;
	room5_action_loop4 = 0;
	room5_action_loop4_fail = 0;
	room5_exit = 0;
	wait(1);
	handle_videos();
}



"MAIN" starts the function "start_into()" and the into video plays once just fine, however, I couldn't manage to let another Video (in this case the loop) play afterwards.

If "start_loop1" is 1, then that loop is suppose to play etc.
I attempted to do this in "handle_videos()".

What did I do wrong?

Last edited by middleagechinese; 10/18/17 07:17.

Hello, it is me,

Middleagedchineseman!

Note: Not actually Chinese, nor middle age
Re: Video control [Re: middleagechinese] #468772
10/18/17 07:34
10/18/17 07:34
Joined: Apr 2002
Posts: 680
Germany
Turrican Offline
User
Turrican  Offline
User

Joined: Apr 2002
Posts: 680
Germany
Have you tried media_playing(var handle) instead of your while(handle_intro_played) loop?

Re: Video control [Re: Turrican] #468778
10/18/17 17:25
10/18/17 17:25
Joined: Jul 2014
Posts: 72
D
DriftWood Offline
Junior Member
DriftWood  Offline
Junior Member
D

Joined: Jul 2014
Posts: 72
As is pointed out by @Turrican the video handle will continue to have a value. So this...
Code:
while(handle_intro_played){wait(1);}


...will continue forever.
Code:
while(media_playing(handle_intro_played)) {wait(1);}


This is pointless...
Code:
media_stop(handle_intro_played);


...as the media_play function is self terminating at end of file.

Try this..
Code:
while(1)
	{
		if(intro_played == 1)
		{
			intro_played = 0;
			var handle_intro_played = media_play("demo.ogg",NULL,100); 
			while(media_playing(handle_intro_played)) {wait(1);}
			start_loop1 = 1;
		}
		if(start_loop1 == 1)
		{
			start_loop1 = 0;
			var handle_start_loop1 = media_loop("demo.ogg",NULL,100); 
		}
		wait(1);
	}



A handle is a reference to an engine object. Not the same but similar to a Pointer. A var set to a handle holds the same handle forever unless explicitly reset to some other value. i.e. var x= handle; x=NULL; --- Using a handler as a boolean value in a clause like WHILE or IF will always equal out to 1 unless the var holding has been reset.

Edit- One last point, you made the loop WHILE(1) ---> Does this loop really need to run forever? Isn't it better to terminate it at some point and save resources.

Last edited by DriftWood; 10/18/17 17:38.
Re: Video control [Re: DriftWood] #468782
10/19/17 08:49
10/19/17 08:49
Joined: Nov 2016
Posts: 31
middleagechinese Offline OP
Newbie
middleagechinese  Offline OP
Newbie

Joined: Nov 2016
Posts: 31
Works perfect, and thank you for the elaborate explanation.

It was suppose to be an infinity loop until input (dialog choice), however an time limit as an penalty and means to save resources is an good idea.
Thank you for the suggestion!


Hello, it is me,

Middleagedchineseman!

Note: Not actually Chinese, nor middle age
Re: Video control [Re: middleagechinese] #468801
10/20/17 13:10
10/20/17 13:10
Joined: Nov 2016
Posts: 31
middleagechinese Offline OP
Newbie
middleagechinese  Offline OP
Newbie

Joined: Nov 2016
Posts: 31
Say, is there a way to pause an video at an specific frame and then start an new video?


Hello, it is me,

Middleagedchineseman!

Note: Not actually Chinese, nor middle age
Re: Video control [Re: middleagechinese] #468824
10/22/17 10:43
10/22/17 10:43
Joined: Apr 2002
Posts: 680
Germany
Turrican Offline
User
Turrican  Offline
User

Joined: Apr 2002
Posts: 680
Germany
You can use media_playing(handle) to return the current frame of your stream, then pause it once it reached its target frame and then start the next one. Something like this should work:

Code:
...
var handle_intro_played = media_play("demo.ogg",NULL,100);			// play your stream
while(media_playing(handle_intro_played) < target_frame_number) { wait(1); }	// keep playing until target_frame_number has been reached
media_pause(handle_intro_played);						// pause the first stream
var handle_next_mediastream = media_play("demo2.ogg",NULL,100);			// start next one
...



Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1