Z
z0mbix
Hi, I am currently writing a proof of concept music player in Ruby and havegot so far, but I need a bit of advice for how to proceed. The music player plays music from a simple json playlist file in a loop. This is simple and already implemented, but what I need to do is play different playlists oneach day of the week, and only during the specified times, so I need some way to schedule events to switch playlists at the specified days/times. I've not had to do anything like this before and not sure what the best approach is. Should there be a separate thread that wakes up every minute to check if a switch is required, or is there a better way to do this?
Here's a sample json schedule file:
{
"playlist-name": "Day Part Schedule",
"description": "This schedule file only plays files during the specified duration",
"monday": [
{
"playlist": "monday.json",
"times": [
"0900-1700",
"1800-1900"
]
}
],
"tuesday": [
{
"playlist": "tuesday.json"
}
],
"wednesday": [
{
"playlist": "wednesday.json",
"times": [
"0900-1730"
]
}
],
"thursday": [
{
"playlist": "thursday.json",
"times": [
"0900-1730"
]
}
],
"friday": [
{
"playlist": "friday.json",
"times": [
"0900-1730"
]
}
],
"saturday": [
{
"playlist": "saturday.json",
"times": [
"0900-1900"
]
}
],
"sunday": [
{
"playlist": "sunday.json",
"times": [
"1000-1630"
]
}
]
}
Here's a sample json schedule file:
{
"playlist-name": "Day Part Schedule",
"description": "This schedule file only plays files during the specified duration",
"monday": [
{
"playlist": "monday.json",
"times": [
"0900-1700",
"1800-1900"
]
}
],
"tuesday": [
{
"playlist": "tuesday.json"
}
],
"wednesday": [
{
"playlist": "wednesday.json",
"times": [
"0900-1730"
]
}
],
"thursday": [
{
"playlist": "thursday.json",
"times": [
"0900-1730"
]
}
],
"friday": [
{
"playlist": "friday.json",
"times": [
"0900-1730"
]
}
],
"saturday": [
{
"playlist": "saturday.json",
"times": [
"0900-1900"
]
}
],
"sunday": [
{
"playlist": "sunday.json",
"times": [
"1000-1630"
]
}
]
}