Author Topic: Pause AM During Intro Movie?  (Read 7219 times)

YellowBirdAZ

  • Full Member
  • ***
  • Posts: 80
    • View Profile
Pause AM During Intro Movie?
« on: August 27, 2017, 12:43:03 AM »
I was trying to add an intro movie to my AM set-up and then quickly realized it just plays over the top of the layout.

So if your intro movie has music or sound, and your layout itself plays ambient sound, they will overlap. It is very annoying.

I've hacked around issues like this before by inserting silent sound files of predetermined lengths to generate audio pauses where needed. I'm reluctant to keep adding hacks though.

Anyone have a solution or suggestion?

I could just launch the intro movie outside of AM, and then launch AM upon the video's completion, but there has to be another way.


keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #1 on: August 27, 2017, 04:57:19 AM »
Silence all objects with sound in your layout until the amount of time your into movie is. You have to dig into the code and use layouts.md as a reference. Look at add ticks and add artwork or add image sections. There are video flags.

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #2 on: August 27, 2017, 06:02:45 AM »
You can do it like keilmillerjr says

something like this

class UserConfig {
      
   </ label="Delay Time (0-999)", help="The amount of time (in milliseconds?) that it takes to wait for start the music", order=1 />
   dtime="100";
   
}
local music_active = false;
local delay = 0;
local max_delay = 0;
menumusic.playing = music_active;

max_delay=abs(("0"+my_config["dtime"]).tointeger())
max_delay=(max_delay>999 ? 100 : max_delay);

::fe.add_ticks_callback( this, "tick_fn" );

function tick_fn( ttime )
   {
      delay++;
      if ( delay > max_delay )
      {      
         if (music_active == false){
            music_active = true;
            menumusic.playing = music_active;                     
         }

      }
   }

The idea is you can configure how long you theme need to wait to start playing the music
« Last Edit: August 28, 2017, 04:31:24 AM by bjose2345 »

YellowBirdAZ

  • Full Member
  • ***
  • Posts: 80
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #3 on: August 28, 2017, 07:14:42 AM »
Thanks guys! I will take a look as soon as I can and report my progress.

YellowBirdAZ

  • Full Member
  • ***
  • Posts: 80
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #4 on: August 28, 2017, 10:03:27 PM »
I started looking at it and realize there might be a wrinkle to my case. The solutions you guys are point to are probably correct, but in my set-up the layout itself isn't handling the music. Instead I wrote a plugin to handle it (it switches music source folders based on which game list I am displaying... so 80s games have 80s music, for instance).

Maybe I just need to figure out how to get my music plugin to wait on start-up. Could probably use similar code to what bjose2345 proposed.

YellowBirdAZ

  • Full Member
  • ***
  • Posts: 80
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #5 on: August 28, 2017, 11:06:20 PM »
OK so I found a way to do it, maybe this will work for others too.

First, I had to set some global variables. Trick for me was to find the right places to do it.

I set INTRO_DELAY to true (that is, wait for the intro to play) and INTRO_DELAY_LENGTH to a number that corresponds roughly to the number of "ticks" (milliseconds?) it takes my intro video to play.

These two globals are set in two places... first in intro.nut.

::INTRO_DELAY <- true;
::INTRO_DELAY_LENGTH <- 28000;

Next, they are set in my layout.nut. But here they receive new values.

::INTRO_DELAY <- false;
::INTRO_DELAY_LENGTH <- 0;

They are different because once the layout.nut runs the need to wait is over. My issue was the music-playing plugin was starting up during intro.nut. I don't really need the delay for the post-intro layouts.

Then I added a check in the on_tick function in my music player plug-in. Once ttime meets or exceeds the value specified in INTRO_DELAY_TIME, INTRO_DELAY gets flipped to false. (Basically, when this condition is satisfied the plug-in is done waiting for the intro.)

   function on_tick( ttime )
   {
      if ( ::INTRO_DELAY && ttime < ::INTRO_DELAY_LENGTH) {
         return false;
      }
      else
      {
         ::INTRO_DELAY <- false;
      }
      if ( fe.ambient_sound.playing == false)
         change_track( 1 );
   }

Then wrapped most of the other functions in the plug-in in a if/then check of INTRO_DELAY. If INTRO_DELAY is still false, the functions dump out with a false return value before they do whatever they are supposed to do. This basically stops the music from playing. (The function that loads and shuffles a playlist is allowed to execute even if INTRO_DELAY is false, because it doesn't actually start playing the music.)

I could have the delay time specified in the UserConfig of the intro.nut. Maybe some error checking. I just didn't do it yet. But this appears to work.
« Last Edit: August 29, 2017, 12:23:38 PM by YellowBirdAZ »

calle81

  • Sr. Member
  • ****
  • Posts: 184
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #6 on: August 29, 2017, 02:15:57 PM »
You can do it like keilmillerjr says

something like this

class UserConfig {
      
   </ label="Delay Time (0-999)", help="The amount of time (in milliseconds?) that it takes to wait for start the music", order=1 />
   dtime="100";
   
}
local music_active = false;
local delay = 0;
local max_delay = 0;
menumusic.playing = music_active;

max_delay=abs(("0"+my_config["dtime"]).tointeger())
max_delay=(max_delay>999 ? 100 : max_delay);

::fe.add_ticks_callback( this, "tick_fn" );

function tick_fn( ttime )
   {
      delay++;
      if ( delay > max_delay )
      {      
         if (music_active == false){
            music_active = true;
            menumusic.playing = music_active;                     
         }

      }
   }

The idea is you can configure how long you theme need to wait to start playing the music

bjose2345, can you help me understand how to use this code snippet? I want to add a delay for video play back. Right now I use FadeArt and Transition.EndNavigation for a smooth experience but the navigation on a weak device like an raspberry Pi I think would benefit if there was a delay before the snap starts playing.

local snap = FadeArt ( "snap", flx*0.183, fly*0.0376, flw*0.635, flh*0.56 );
snap.trigger = Transition.EndNavigation;
snap.preserve_aspect_ratio = true;

bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #7 on: August 30, 2017, 01:18:20 PM »
hi calle81,

well the main idea is to have 2 flags and 1 timer

the function tick_fn( ttime ){} Does not have much loss there, just keep ticking a executing everyting inside the block

the first flag (max_delay) will help you to control the time in which you want to run the code

the second flag (music_active) will help to keep at bay the code inside the timer (Avoid repeating indefinitely, will execute only once or each time the layout.nut is loaded)

calle81

  • Sr. Member
  • ****
  • Posts: 184
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #8 on: August 30, 2017, 01:51:56 PM »
hi calle81,

well the main idea is to have 2 flags and 1 timer

the function tick_fn( ttime ){} Does not have much loss there, just keep ticking a executing everyting inside the block

the first flag (max_delay) will help you to control the time in which you want to run the code

the second flag (music_active) will help to keep at bay the code inside the timer (Avoid repeating indefinitely, will execute only once or each time the layout.nut is loaded)

Ok, I understand the concept but still not clear on where to put the lines to make it play the snap. I'm slowly learning this scripting stuff so excuse my noob questions. This what i entered in my theme but it breaks it and does not get further to display the wheel etc which is beneath this code:

local snap_active = false;
local delay = 0;
local max_delay = 0;
snap.playing = snap_active;

max_delay=abs(("0"+my_config["dtime"]).tointeger())
max_delay=(max_delay>999 ? 100 : max_delay);

::fe.add_ticks_callback( this, "tick_fn" );

function tick_fn( ttime )
   {
      delay++;
      if ( delay > max_delay )
      { 
         if (snap_active == false){
            snap_active = true;
            snap.playing = snap_active;
      local snap = FadeArt ( "snap", flx*0.183, fly*0.0376, flw*0.635, flh*0.56 );
      snap.trigger = Transition.EndNavigation;
      snap.preserve_aspect_ratio = true;         
         }
      
      }
   }


bjose2345

  • Sr. Member
  • ****
  • Posts: 107
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #9 on: August 30, 2017, 03:08:26 PM »
hmm i think you need to change from the fadeart module to the animation in this case.

here is some example

http://forum.attractmode.org/index.php?topic=744.0

calle81

  • Sr. Member
  • ****
  • Posts: 184
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #10 on: September 05, 2017, 06:55:04 AM »
The problem is that even if I change it to just display an image the code seems to loop and does not show the image or proceed to display the wheel etc which is beneath the loop. Can you see if there is something missing in the code that does not allow it to proceed?

/Carl

calle81

  • Sr. Member
  • ****
  • Posts: 184
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #11 on: September 07, 2017, 02:10:15 PM »
Dumbed it down to troubleshoot but is does not seem to add any ticks:

local delay = 0;
local max_delay= 100;

::fe.add_ticks_callback( this, "tick_fn" );
function tick_fn( ttime )
{
delay++;
if ( delay > max_delay )
{

local test_art = fe.add_image("background/carbon.png", 0, 0, flw, flh );
test_art.alpha=255;
}
}

calle81

  • Sr. Member
  • ****
  • Posts: 184
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #12 on: September 08, 2017, 12:31:11 PM »
The animation module doesn't seem to help either. The delay value does not halt the snap from playing. The snap starts playing and then after 1 sec the animation kicks in making it look really weird.


local snap = fe.add_artwork( "snap" , 0, 0, flw, flh);
snap.preserve_aspect_ratio = true;
snap.trigger = Transition.EndNavigation;
local snapfade = {

   when = Transition.ToNewSelection
   property = "alpha",
   start = 0,
   end = 255,
        time = 7000,
   pulse = false
   delay = 1000
}
animation.add( PropertyAnimation ( snap, snapfade ) );   

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #13 on: September 08, 2017, 03:49:11 PM »
So… I just added an intro movie for testing on my mac (due to this thread) and something interesting happened. Layout did not load until intro was complete. Hmmm… I’ll transfer and test on my arcade machine running windows some time soon. What OS are you guys using where the intro plays over the layout?

kent79

  • Hero Member
  • *****
  • Posts: 842
    • View Profile
Re: Pause AM During Intro Movie?
« Reply #14 on: September 15, 2017, 05:31:56 PM »
Sorry, I have tried to make it possible, but no luck. I think it can't do it in this moment since it is a bugs for AM