Need assistance in how to "resume" a song playing #144
-
I am trying to play a sound that resumes at a specific time in seconds when it was last active. I am currently storing the seconds that the song has been playing in the player_config via a timer but I am unsure how to use that value as a parameter to the "start_at" in the sound_player configuration.
The error I get in the log files when attempting to start MPF is which I am assuming is due to the parsing of the configuration file before the configuration for a player can even initialise its value to 0 (see the snippet from my config file):
I am using the latest pre-release version of MPF and Godot. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
First thing is player_vars default to type string. Add an argument below initial_value of value_type: intThe error can’t convert the value (string) to what it needs (int).Sent from my iPhoneOn Aug 19, 2024, at 8:15 PM, Mark Bernardinis ***@***.***> wrote:
I am trying to play a sound that resumes at a specific time in seconds when it was last active. I am currently storing the seconds that the song has been playing in the player_config via a timer but I am unsure how to use that value as a parameter to the "start_at" in the sound_player configuration.
sound_player:
mode_song1_started:
song1:
action: play
bus: music #temporary workaround
start_at: (current_player.active_song_seconds)
The error I get in the log files when attempting to start MPF is which I am assuming is due to the parsing of the configuration file before the configuration for a player can even initialise its value to 0 (see the snippet from my config file):
mpf.exceptions.config_file_error.ConfigFileError: Config File Error in ConfigValidator: Failed to load config player mode_song1_started:sounds with settings {'song1{current_player.active_song_seconds != None}': {'action': 'play', 'bus': 'music', 'start_at': '(current_player.active_song_seconds)', 'block': False, 'delay': None, 'volume': None, 'ducking': {}, 'pan': None, 'loops': None, 'priority': None}} >> Config validation error: Entry sound_player:sound_player:start_at = "(current_player.active_song_seconds)" is not valid. Cannot convert value to secs. Error Code: CFE-ConfigValidator-11 (https://missionpinball.org/logs)
player_vars:
active_song_seconds:
initial_value: 0 # not being initialised in time
I am using the latest pre-release version of MPF and Godot.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Ahh, good catch. I was looking at wrong thing. What it’s yelling at is that you have an int, but it’s not in a time format. I’m not sure when I will have time to look into this one, but can try later this week if no one else gets to it.Sent from my iPhoneOn Aug 20, 2024, at 3:49 AM, Mark Bernardinis ***@***.***> wrote:
Thanks - I'll give it a try tomorrow, but I did think it defaulted to int as per the documentation (not string).
image.png (view on web)
https://missionpinball.org/latest/config/player_vars/
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
OK, I have gone through the code briefly (not debugging interactively) but it appears as though the start_at value cannot handle values that are dynamically calculated at runtime using variables. I may be wrong but that is what it looks like. The question is, is this something that should be supported and is a bug or something that is not support and is therefore a feature??? |
Beta Was this translation helpful? Give feedback.
-
Ah hah, yes the documentation looks misleading to say the value should be an |
Beta Was this translation helpful? Give feedback.
-
Okay, it was a bit more complex than I was hoping because players like Please take a look! |
Beta Was this translation helpful? Give feedback.
Okay, it was a bit more complex than I was hoping because players like
sound_player
use nested dictionaries to pass multiple triggers from a single event. On the plus side, this change will apply to all config players and all template types, so it could be a big win for the future.Please take a look!
missionpinball/mpf#1824