From ae5cea9c626fecb796e2a3202b6c233f8439b67b Mon Sep 17 00:00:00 2001 From: michael-grace Date: Wed, 4 Nov 2020 00:09:42 +0000 Subject: [PATCH] fixed some errors --- plan.py | 7 +++++++ player.py | 12 +++--------- server.py | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/plan.py b/plan.py index 072bc34..f76b9e6 100644 --- a/plan.py +++ b/plan.py @@ -13,6 +13,7 @@ """ from typing import Dict +import os class PlanObject: _timeslotitemid: int = 0 @@ -47,4 +48,10 @@ class PlanObject: self._filename = new_item["filename"] self._title = new_item["title"] self._artist = new_item["artist"] + + # Fix any OS specific / or \'s + if os.path.sep == "/": + self._filename = self.filename.replace("\\", '/') + else: + self._filename = self.filename.replace("/", '\\') \ No newline at end of file diff --git a/player.py b/player.py index 2ec3879..6c531c2 100644 --- a/player.py +++ b/player.py @@ -32,14 +32,14 @@ from plan import PlanObject import os import sys -os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" + from pygame import mixer from mutagen.mp3 import MP3 from state_manager import StateManager from helpers.os_environment import isMacOS - +os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide" class Player(): state = None @@ -232,12 +232,6 @@ class Player(): def load(self, timeslotitemid: int): if not self.isPlaying: self.unload() - # Fix any OS specific / or \'s - if os.path.sep == "/": - filename = filename.replace("\\", '/') - else: - filename = filename.replace("/", '\\') - updated: bool = False @@ -317,7 +311,7 @@ class Player(): self.state.update("remaining", self.state.state["length"] - self.state.state["pos_true"]) - if self.state.state["remaining"] == 0: + if self.state.state["remaining"] == 0 and self.state.state["loaded_item"]: # Track has ended print("Finished", self.state.state["loaded_item"].name) diff --git a/server.py b/server.py index 0a55575..d3de3b1 100644 --- a/server.py +++ b/server.py @@ -153,12 +153,12 @@ def autoadvance(channel: int, state: int): return ui_status() @app.route("/player//repeat/") -def autoadvance(channel: int, state): +def repeat(channel: int, state): channel_to_q[channel].put("REPEAT:" + state.upper()) return ui_status() @app.route("/player//playonload/") -def autoadvance(channel: int, state: int): +def playonload(channel: int, state: int): channel_to_q[channel].put("PLAYONLOAD:" + str(state)) return ui_status()