Replicating UMP time markers

Topics related to using ToolBook for building web apps.

Replicating UMP time markers

Postby Geoff Pearson » Sat Jan 02, 2016 7:17 pm

I have just installed PowerPac & struggling a bit to get a handle on it. Had a look at Help/Tutorials but couldn't find anything relevant to my needs which right now are pretty fundamental!

Is there a Powerpac function library (like the old Openscript reference library)? In the application I am trying to update, I have used UMPs making extensive use of time-markers. Actions scripts in each UMP uses "on media timing events" to trigger interactions elsewhere in the simulator. In essence, what I need to be able to do with Powerpac is load - open - play an audio clip with timed events at various points throughout the clip. Is there a way of doing this with Powerpac? Any insight appreciated.

Geoff Pearson
Geoff Pearson
 
Posts: 14
Joined: Sun Jan 19, 2014 11:08 pm

Re: Replicating UMP time markers

Postby Clifton » Sat Jan 02, 2016 8:54 pm

To emphasize: You should not use the UMP at all. It will not work in HTML 5 projects very well because it relies on ActiveX controls in IE and other plugins depending on the audio type you wish to use. Instead, always use PowerPac's media player functions/actions to support audio. They work in all browsers and generally on all devices.

To play your mp3 audio files, you would use the PowerPac function pgSoundLoader(). It has full support for time markers with notifications, including end of audio notification, etc. The related PowerPac function called pgSoundControl() allows you manipulate an audio file that was loaded using pgSoundLoader(). These two functions enable you to pretty much do anything you can imagine with audio (mp3 not wav) files.

In the example below, click on "Load Audio" to simulate what would ordinarily happen with the on load page event. When the audio plays, it triggers a user event at 1500 and 3200 milliseconds. It also sends an end of audio notification. You can see the event [value] parameter that is shown in the red field of the example as the audio plays.

HOW TO DO THIS:
  1. Follow the instructions on the page shown above.
  2. Set up the "AudioPlayer" field with these parameters:
    NOTE: I put this action on the trigger event of the "AudioPlayer" field, but ordinarily it would be placed on load page. Also, if you don't want playback controls, then hide the field and leave showControls empty or unset. If you do not want the audio to play right away, then set action = "pause" as the default is "play"
      pbox.png
      Example:
      pgSoundLoader() parameters
      pbox.png (46.93 KiB) Viewed 4299 times
  3. Set up the on user event of the "AudoPlayer" field with these actions:
    NOTE: The [value] parameter of this event contains the string "audio,[position]" where [position] can be a time marker integer (e.g.: 1500, or 3200 in this case because these are timeMarkers we defined above) or the string "end" when the audio reaches the end of the audio file. The pgTBObjSet() actions merely set the text or htmlText of the red "Events" field and control the reset of the object when the audio reaches the end.
      User Event.png
      User Event Actions
      Example only!!
      User Event.png (34.37 KiB) Viewed 4299 times
  4. I usually put all my mp3 audio files in folder called [audio] and flag that folder to be included in the ToolBook exported content. The DHTML Export Tree Manager utility is provided for this purpose. The image below shows what the export tree looks like after adding the [audio] folder.
      DHTML Export Tree Manager.png
      DHTML Export Tree Manager
      Flag the [audio] folder to be included in the export.
      DHTML Export Tree Manager.png (97.21 KiB) Viewed 4299 times
This should get you going with audio. Read carefully the popup help, etc. for other options and capabilities.

Additional Help for PowerPac Functions and Parameters:
The hot key Ctrl+Shift+P opens the Parameter Help Index shown below. It can be accessed from the PowerPac menu as well.
    paramHelp.png
    Parameter Help Index
    paramHelp.png (57.68 KiB) Viewed 4294 times

Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Replicating UMP time markers

Postby Geoff Pearson » Sat Jan 23, 2016 8:38 pm

Hello There,

I'm having trouble figuring out how to intercept audio clip time markers that I want to use in a complex simulator. I have the required audio clip loading & playing just fine with the timer intervals defined in the "timed markers" field of the "pgSoundLoader". But, nothing I have tried allows me to intercept those timed signals. I am using the AE "OnUserEvent" eg...

COMMENT timer 1000
executeScript pgObjSet (HTML)
set visible of button "TRIP" to true

I tried pgObjGet & several others but nothing works for me. I am probably missing something stupidly obvious but sure would appreciate any advice as I;ve spent the whole morning on this & gone nowhere!

Geoff Pearson
Geoff Pearson
 
Posts: 14
Joined: Sun Jan 19, 2014 11:08 pm

Re: Replicating UMP time markers

Postby Clifton » Sat Jan 23, 2016 9:09 pm

The above example I posted used a couple of time markers. Each time a marker is reached in the audio playback, the object specified by the name parameter in pgSoundLoader() will receive a user event with the value parameter formatted as "audio,[time marker in milliseconds],time".

To act on a specific time marker that is reached, you would use the action code:
    If item 2 of value = [time marker]
    ... do some stuff ...
    end if
This code MUST be placed on the user event for the object that corresponds to the name parameter when pgSoundLoader() started playing the audio.
The name parameter is a reference to the name of a ToolBook object that should be a container for controls (optional and usually just a simple field, whether visible or hidden) AND it is the target object that receives the user events.

If you still have trouble, you may have to post a more specific example of what is failing.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Replicating UMP time markers

Postby Geoff Pearson » Sat Jan 23, 2016 9:56 pm

Hi Clifton,

As you can see on the attached file, my mp3 file is named "startup". pgSoundLoader loads the audio files on loadpage.

I have broken the simulation down into manageable chunks & the AE script for the "startup" sequence is in a button named "starttimer" which gets triggered by a user action elsewhere on the page. The audio loads & runs fine.

Under "User Event" in the "starttimer" button, I have...

comment TIMER 1000
If item 1 of "startup" = 1000
set visible of button "TRIP" to true
End if

comment TIMER 7940
if item 2 of "startup" = 7940
set visible of Animated GIF placeholder "PREPURGE" to true
End if

and so on.

Does anything jump out at you?

Geoff Pearson
Attachments
ppac1.gif
ppac1.gif (82.46 KiB) Viewed 4283 times
Geoff Pearson
 
Posts: 14
Joined: Sun Jan 19, 2014 11:08 pm

Re: Replicating UMP time markers

Postby Clifton » Sat Jan 23, 2016 10:22 pm

Thank you for the more detailed logic.
Based on your logic, this is what will happen:
  • The audio will load, but will not begin playing until you tell it to. Most likely you will have to make a call to pgSoundControl() to make it play.
  • When the audio begins playing, it locks it's communication with an object called "startup".
  • Your time marker list will be sorted from smallest to largest.
  • When the first time marker is reached, the object named "startup" will receive a notification or user event with the value parameter set to "audio,1000". You would check ...
    item 2 of value
    ... to determine which marker has been reached during playback.
  • Each successive time marker reached will cause a user event to be sent to the object named "startup".
So, where is the problem?
Answer: You probably DO NOT HAVE AN OBJECT NAMED "startup" on the page OR it may be that the object named "startup" does not intercept user events (i.e: there are no on user event actions on it). Therefore, the events are being sent nowhere. In your logic, you seem to be using a button called "starttimer" to track the playback events. If that is your intention, then you have to change the "name" parameter in pgSoundLoader() to "starttimer" so a real object can be sent the events. Then add your actions to the on user event for that object.

Understanding user events has been one of the more troublesome things for new PowerPac users. This is because most developers have had no use for these events in the past. However, the fact is this is one of the most powerful Actions Editor features that can be leveraged to provide user feedback and notifications from JavaScript functions.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Replicating UMP time markers

Postby Geoff Pearson » Sun Jan 24, 2016 1:49 am

Thanks Clifton for your trouble. Got it!!... I renamed the name field in the pgOpen handler & suddenly it worked!

GP
Geoff Pearson
 
Posts: 14
Joined: Sun Jan 19, 2014 11:08 pm

Re: Replicating UMP time markers

Postby Geoff Pearson » Sun Jan 24, 2016 4:01 am

I'm back!! I thought I fixed it but, it's just breezing through my AE script without intercepting the time markers.

The mp3 file opens & pauses on loadpage. I have "startup" in the name field of pgSoundLoad.

I have a button on the page named "startup". The "on click" action is "Execute script pgSoundControl" name field = "startup" action field = "play"

The mp3 file starts playing... so far no problem.

On User Event of the button "startup" I have...
if item 1 of "startup" =1000
set visible of button "trip" to true
End if

if item 2 of "startup" = 7940
set visible of Animated GIF placeholder "PREPURGE" to true
end if

and so on.

It doesn't work... I don't get to see the animated gif.

Have I got the syntax right? It looks suspiciously simple to me... like, should I not be querying the clip for "position" (like get mmPosition)? If affirmative, how do you do that? I have double checked the time markers & the values match. Is there an example anywhere that I can look at? I searched the website but nothing in the samples gives me a clear picture.

Geoff Pearson
Geoff Pearson
 
Posts: 14
Joined: Sun Jan 19, 2014 11:08 pm

Re: Replicating UMP time markers

Postby Clifton » Sun Jan 24, 2016 6:30 am

Please change ...
    if item 1 of "startup" =1000
    set visible of button "trip" to true
    End if

    if item 2 of "startup" = 7940
    set visible of Animated GIF placeholder "PREPURGE" to true
    end if

TO ...
    if item 2 of value = "end"
    COMMENT: Do some stuff when the audio has finished playing; this is good practice but not required.
    else if item 2 of value =1000
    set visible of button "trip" to true
    else if item 2 of value = 7940
    set visible of Animated GIF placeholder "PREPURGE" to true
    end if

    ... and it should work fine.

    NOTE: in your original code
    item 2 of "startup"
    is simply evaluating item 2 of the comma-separated string "startup" and returning "" (or an empty string) because there is no item 2 in the string. If your code was
    item 2 of "startup,1000"
    the result would have been 1000 because item 2 of the comma-separated string is the integer 1000. However, none of that would mean anything to what is actually happening when a user event is sent to your object since the comma-separated string to check is contained in the [value] parameter of the on user event. Item 1 of this string is always "audio" and item 2 is always your time marker OR it is the string "end" to indicate the audio has finished playing.
Remember:
  • When an on user event is sent to an object, the event receives one variable or parameter with the event and that variable is called [value].
  • The PowerPac usually sets the [value] parameter when sending on user events so developers can manipulate the content on the page.
  • PowerPac's popup help window always documents the format of the [value] parameter so you can know what to do with your actions for the on user event.
  • If you look at my example early in this thread, you will see how I am working with the [value] parameter in my on user event in the sample player. This is a real time example so you can click to load the audio and see the playback result.
  • All of this is in the PowerPac documentation, but admittedly this is often part of the learning curve. Most PowerPac functions use a similar convention when notifying of events and sending data.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: Replicating UMP time markers

Postby Geoff Pearson » Sun Jan 24, 2016 6:43 am

Hi Clifton,

Don't you sleep?

I'll try this tomorrow.

Just watched the news.. hope the blizzard hasn't treated you too badly.

Geoff Pearson
Geoff Pearson
 
Posts: 14
Joined: Sun Jan 19, 2014 11:08 pm

Next

Return to Web (DHTML) Development

Who is online

Users browsing this forum: No registered users and 5 guests

cron