mpy files duration
Hello,
I am designing an experiment where participants will view a sequence of 4 items, comprising 1 randomly selected video file and 3 static images. The video file will be displayed at a random position in the sequence with a random duration. I'm currently working on a script to implement this experiment and need advice on handling the randomly chosen durations for the video objects.
if var.position == 1:
import random
videos = ["clip1.mp4", "clip2.mp4", "clip3.mp4", "clip4.mp4"]
video= random.choice(videos)
durations = [300,350,400,450,500]
video_duration = random.choice(durations)
I have the above code implemented as an inline script. Additionally, there's another script for randomly choosing images without any position condition. Then, I proceed with a sketchpad and an mpy object.
Questions,
- Is using a duration variable in the script of the mpy object the appropriate approach for handling randomly picked durations for video objects?
- Are there any optimizations or improvements I can make to this script for better performance or functionality?"
Thanks
Comments
Hi @Mikefiels ,
Is using a duration variable in the script of the mpy object the appropriate approach for handling randomly picked durations for video objects?
Do I understand correctly that you're specifying the duration by entering
{video_duration}into the duration field of themedia_player_mpy? If so, then yes, that's indeed the way to go.Are there any optimizations or improvements I can make to this script for better performance or functionality?
I don't know the details of the experiment, of course. But in general the script looks fine!
— Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!