fixed some errors

This commit is contained in:
michael-grace 2020-11-04 00:09:42 +00:00
parent 51ae3033b9
commit ae5cea9c62
3 changed files with 12 additions and 11 deletions

View file

@ -13,6 +13,7 @@
""" """
from typing import Dict from typing import Dict
import os
class PlanObject: class PlanObject:
_timeslotitemid: int = 0 _timeslotitemid: int = 0
@ -47,4 +48,10 @@ class PlanObject:
self._filename = new_item["filename"] self._filename = new_item["filename"]
self._title = new_item["title"] self._title = new_item["title"]
self._artist = new_item["artist"] 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("/", '\\')

View file

@ -32,14 +32,14 @@ from plan import PlanObject
import os import os
import sys import sys
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
from pygame import mixer from pygame import mixer
from mutagen.mp3 import MP3 from mutagen.mp3 import MP3
from state_manager import StateManager from state_manager import StateManager
from helpers.os_environment import isMacOS from helpers.os_environment import isMacOS
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
class Player(): class Player():
state = None state = None
@ -232,12 +232,6 @@ class Player():
def load(self, timeslotitemid: int): def load(self, timeslotitemid: int):
if not self.isPlaying: if not self.isPlaying:
self.unload() self.unload()
# Fix any OS specific / or \'s
if os.path.sep == "/":
filename = filename.replace("\\", '/')
else:
filename = filename.replace("/", '\\')
updated: bool = False updated: bool = False
@ -317,7 +311,7 @@ class Player():
self.state.update("remaining", self.state.state["length"] - self.state.state["pos_true"]) 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 # Track has ended
print("Finished", self.state.state["loaded_item"].name) print("Finished", self.state.state["loaded_item"].name)

View file

@ -153,12 +153,12 @@ def autoadvance(channel: int, state: int):
return ui_status() return ui_status()
@app.route("/player/<int:channel>/repeat/<state>") @app.route("/player/<int:channel>/repeat/<state>")
def autoadvance(channel: int, state): def repeat(channel: int, state):
channel_to_q[channel].put("REPEAT:" + state.upper()) channel_to_q[channel].put("REPEAT:" + state.upper())
return ui_status() return ui_status()
@app.route("/player/<int:channel>/playonload/<int:state>") @app.route("/player/<int:channel>/playonload/<int:state>")
def autoadvance(channel: int, state: int): def playonload(channel: int, state: int):
channel_to_q[channel].put("PLAYONLOAD:" + str(state)) channel_to_q[channel].put("PLAYONLOAD:" + str(state))
return ui_status() return ui_status()