If you are using CP9, CP2017 or CP2019: go to a more recent post which offers an easier and better workflow for this toggle button:
Intro
This a quick tip, to avoid me having to answer this question again and again on the user forum. It is pretty easy to have custom buttons to navigate to previous, next or even last visited slides, or to toggle CC. But the play/pause button is a bit trickier. The reason is that for this button 'twin' system variables are involved: rdcmndPause and rdcmndResume. In this post I offer three solutions. Watch the movie to see the difference/
Example
Watch this movie to judge the difference between the solutions. I reused some slides from a previous post (Playtime with audio and widgets) that have a bit complex and long timelines to allow you to test the Pause/Play functionality. You'll experience the three solutions in this sequence:
- on the first slide, clicking the Pause button, will make it disappear and the Play button will show up: simplest solution with two buttons
- on the second slide, there is only one button with the text 'Play/Pause) that is already a real toggle, but its aspect will always be the same
- on the third and fourth slide you'll find also a toggle button, but the text will change to show you are now pausing or playing
Work flows
Solution 1: Play button and Pause button
On the first slide at the start only the Pause button, labeled BtPause is visible, whereas the second BtPlay is hidden. If you expect the user to return to this slide, you'd better set this situation on entering the slide by another standard advanced action. Both buttons trigger a standard advanced action, PauseBt/PlayBt (see screenshots in the Gallery) with these statements:
-
Assign rdcmndPause with 1 (for action PauseBt) or Assign rdcmndResume with 1 (for action PlayBt)
here you see why I call those system variables 'twins' - Hide BtPause (for action PauseBt) or Hide BtPlay (for action PlayBt)
- Show BtPlay (for action PauseBt) or Show BtPause (for action PlayBt))
If you use this action on more than one slide, you'll have to create a duplicate action for each slide, because of the ID's of the buttons that will be unique on each slide.
Warning: do not try to put those buttons on top of each other, perhaps to simulate the behavior of a toggle button, because this will not function!
Solution 2: Toggle button with text 'Play/Pause'
The second slide has an example of this toggle, with the disadvantage that the user doesn't see which state the movie has: paused or not.
Here a conditional action PlayPauseBt is needed, with one single decision (see screenshots: both Then and Else images are available).
IF: rdcmndPause is equal to 0
If this is the case, the movie is playing
THEN: Assign rdcmndPause with 1
the movie will be paused
ELSE: Assign rdcmndResume with 1
the movie will resume playing
If this is the case, the movie is playing
THEN: Assign rdcmndPause with 1
the movie will be paused
ELSE: Assign rdcmndResume with 1
the movie will resume playing
If you do not mind the fact that the button will always have the same aspect this is really the simplest solution, because the action has no reference whatever to an object. This means that you can use it multiple times without haveing to create duplicates or have editing work.
Same remark: you can also replace this button with your custom button, perhaps replace the text by an icon etc.
Solution 3: Toggle button with text 'Play/Pause'
This button can be found on the third/fourth slide. This time I used a blank image button BtPlayOrPause1/BtPlayOrPause2 (one ID per slide), accompanied by two Text Captions: TCPause1 & TCPlay1 for slide 3, TCPause2 & TCPlay2 for slide 3. I need again a conditional advanced action, but reusing it will force you to make duplicates because object ID's are used in the action. In the Gallery you'll find screenshots for the action PlayOrPauseBt1 that is activated by the first toggle on slide 3.
IF: rdcmndPause is equal to 0
If this is the case, the movie is playing
THEN:
If this is the case, the movie is playing
THEN:
Assign rdcmndPause with 1 the movie will be paused
Hide TCPause1 the text Pause will be hidden
Show TCPlay1 text Play will be visible
ELSE:
Assign rdcmndResume with 1 the movie will resume playingHide TCPlay1Show TCPause1
Conclusion
If you want me to create a template with the advanced actions, post a comment. These actions are pretty simple, only the labeling and editing part if you use them a lot in a project are bothersome. One of my secret hopes is that in a future version of CP it will be possible to insert interactive objects on a master slide and the issue with the unique ID's will be solved.