corectly updated
This commit is contained in:
@@ -1 +1 @@
|
||||
{"screen_orientation": "Landscape", "screen_name": "tv-terasa", "quickconnect_key": "8887779", "server_ip": "digi-signage.moto-adv.com", "port": "80"}
|
||||
{"screen_orientation": "Landscape", "screen_name": "tv-panou1", "quickconnect_key": "8887779", "server_ip":"172.20.10.9", "port": "80"}
|
||||
3568
src/Resurse/log.txt
3568
src/Resurse/log.txt
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,6 +1,6 @@
|
||||
from kivy.config import Config
|
||||
Config.set('kivy', 'video', 'ffpyplayer')
|
||||
Config.set('ffpyplayer', 'audio', 'on') # Enable audio
|
||||
|
||||
|
||||
# Now import other Kivy modules
|
||||
from kivy.app import App
|
||||
@@ -27,7 +27,7 @@ Builder.load_file('kv/media_player.kv')
|
||||
CONFIG_FILE = './Resurse/app_config.txt'
|
||||
|
||||
class MediaPlayer(Screen):
|
||||
"""Main screen for media playback."""
|
||||
# Main screen for media playback.
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(MediaPlayer, self).__init__(**kwargs)
|
||||
@@ -51,7 +51,7 @@ class MediaPlayer(Screen):
|
||||
self.hide_button_timer = Clock.schedule_once(self.hide_buttons, 10)
|
||||
|
||||
def on_touch_down(self, touch):
|
||||
"""Handle touch events to reset the button visibility."""
|
||||
# Handle touch events to reset the button visibility.
|
||||
self.show_buttons() # Make all buttons visible
|
||||
if hasattr(self, 'hide_button_timer'):
|
||||
Clock.unschedule(self.hide_button_timer) # Cancel the existing hide timer
|
||||
@@ -59,26 +59,26 @@ class MediaPlayer(Screen):
|
||||
return super(MediaPlayer, self).on_touch_down(touch)
|
||||
|
||||
def hide_buttons(self, *args):
|
||||
"""Hide all buttons after inactivity."""
|
||||
# Hide all buttons after inactivity.
|
||||
self.ids.settings_button.opacity = 0 # Hide the Home button
|
||||
self.ids.right_arrow_button.opacity = 0 # Hide the Right Arrow button
|
||||
self.ids.play_pause_button.opacity = 0 # Hide the Play/Pause button
|
||||
self.ids.left_arrow_button.opacity = 0 # Hide the Left Arrow button
|
||||
|
||||
def show_buttons(self):
|
||||
"""Show all buttons."""
|
||||
# Show all buttons.
|
||||
self.ids.settings_button.opacity = 1 # Show the Home button
|
||||
self.ids.right_arrow_button.opacity = 1 # Show the Right Arrow button
|
||||
self.ids.play_pause_button.opacity = 1 # Show the Play/Pause button
|
||||
self.ids.left_arrow_button.opacity = 1 # Show the Left Arrow button
|
||||
|
||||
def on_key_down(self, window, key, *args):
|
||||
"""Handle key events for toggling fullscreen mode."""
|
||||
# Handle key events for toggling fullscreen mode.
|
||||
if key == 102: # 'f' key
|
||||
Window.fullscreen = not Window.fullscreen
|
||||
|
||||
def on_enter(self):
|
||||
"""Called when the screen is entered."""
|
||||
# Called when the screen is entered.
|
||||
self.playlist = load_playlist() # Load the playlist
|
||||
download_media_files(self.playlist) # Download media files from the playlist
|
||||
clean_unused_files(self.playlist) # Remove unused files from the resource folder
|
||||
@@ -86,7 +86,7 @@ class MediaPlayer(Screen):
|
||||
self.show_buttons() # Ensure buttons are visible when the screen is entered
|
||||
|
||||
def log_event(self, file_name, event):
|
||||
"""Log the start or stop event of a media file and clean up old logs."""
|
||||
# Log the start or stop event of a media file and clean up old logs.
|
||||
# Get the current timestamp
|
||||
timestamp = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
log_message = f"{timestamp} - {event}: {file_name}\n" # Format the log message
|
||||
@@ -100,7 +100,7 @@ class MediaPlayer(Screen):
|
||||
self.cleanup_old_logs()
|
||||
|
||||
def cleanup_old_logs(self):
|
||||
"""Delete log entries older than 24 hours."""
|
||||
# Delete log entries older than 24 hours.
|
||||
try:
|
||||
# Read all log entries
|
||||
if os.path.exists(self.log_file):
|
||||
@@ -133,7 +133,7 @@ class MediaPlayer(Screen):
|
||||
Logger.error(f"Failed to clean up old logs: {e}")
|
||||
|
||||
def play_media(self):
|
||||
"""Play the current media in the playlist."""
|
||||
# Play the current media in the playlist.
|
||||
if self.playlist:
|
||||
media = self.playlist[self.current_index] # Get the current media
|
||||
file_name = media.get('file_name', '') # Get the file name
|
||||
@@ -146,6 +146,16 @@ class MediaPlayer(Screen):
|
||||
|
||||
Logger.info(f"Playing media: {file_path}")
|
||||
|
||||
# Check if the file exists
|
||||
if not os.path.exists(file_path):
|
||||
Logger.error(f"Media file not found: {file_path}")
|
||||
return
|
||||
|
||||
# Cancel any existing timers
|
||||
if self.image_timer:
|
||||
Logger.info("Canceling existing image timer.")
|
||||
Clock.unschedule(self.image_timer)
|
||||
|
||||
# Log the start of the media
|
||||
self.log_event(file_name, "STARTED")
|
||||
|
||||
@@ -172,14 +182,17 @@ class MediaPlayer(Screen):
|
||||
self.image_display.opacity = 0 # Hide the image display
|
||||
|
||||
# Schedule the next media after the video's duration
|
||||
Clock.schedule_once(self.next_media, self.video_player.duration)
|
||||
if self.video_player.duration > 0:
|
||||
Clock.schedule_once(self.next_media, self.video_player.duration)
|
||||
else:
|
||||
Logger.warning("Video duration is unknown. Using default duration")
|
||||
|
||||
def show_image(self, file_path, duration):
|
||||
"""Display an image with a fade-in effect."""
|
||||
# Display an image with a fade-in effect.
|
||||
Logger.info(f"Showing image: {file_path}")
|
||||
if not os.path.exists(file_path):
|
||||
Logger.error(f"Image file not found: {file_path}")
|
||||
return
|
||||
#return # Ensure this return is properly indented within the method
|
||||
|
||||
# Set the image source
|
||||
self.image_display.source = file_path
|
||||
@@ -197,29 +210,39 @@ class MediaPlayer(Screen):
|
||||
def next_media(self, dt=None):
|
||||
"""Move to the next media in the playlist."""
|
||||
Logger.info("Navigating to the next media.")
|
||||
|
||||
# Cancel any existing timers
|
||||
if self.image_timer:
|
||||
Logger.info("Canceling image timer.")
|
||||
Clock.unschedule(self.image_timer)
|
||||
|
||||
# Update the current index
|
||||
self.current_index = (self.current_index + 1) % len(self.playlist)
|
||||
|
||||
# Check if a playlist update is pending
|
||||
if self.is_playlist_update_pending and self.current_index == 0:
|
||||
Logger.info("Applying pending playlist update.")
|
||||
self.playlist = self.updated_playlist # Apply the updated playlist
|
||||
self.updated_playlist = None # Clear the updated playlist
|
||||
self.is_playlist_update_pending = False # Reset the pending flag
|
||||
|
||||
# Play the next media
|
||||
self.play_media()
|
||||
|
||||
def previous_media(self):
|
||||
"""Go to the previous media in the playlist."""
|
||||
"""Move to the previous media in the playlist."""
|
||||
Logger.info("Navigating to the previous media.")
|
||||
|
||||
# Cancel any existing timers
|
||||
if self.image_timer:
|
||||
Logger.info("Canceling image timer.")
|
||||
Clock.unschedule(self.image_timer)
|
||||
|
||||
# Update the current index
|
||||
self.current_index = (self.current_index - 1) % len(self.playlist)
|
||||
|
||||
# Play the previous media
|
||||
self.play_media()
|
||||
|
||||
def toggle_play_pause(self):
|
||||
"""Toggle the play/pause button state and update its appearance."""
|
||||
#Toggle the play/pause button state and update its appearance.
|
||||
self.manage_play_pause_state()
|
||||
|
||||
def manage_play_pause_state(self):
|
||||
"""Manage the state of the play/pause button and media playback."""
|
||||
# Manage the state of the play/pause button and media playback.
|
||||
if self.is_paused:
|
||||
Logger.info("Resuming media playback.")
|
||||
self.video_player.state = 'play'
|
||||
@@ -249,14 +272,14 @@ class MediaPlayer(Screen):
|
||||
self.ids.play_pause_button.background_down = './Resurse/pause.png'
|
||||
self.ids.play_pause_button.background_normal = './Resurse/pause.png'
|
||||
|
||||
# Start a timer to reset the button state after 3 minutes
|
||||
self.reset_timer = Clock.schedule_once(self.reset_play_pause_state, 180)
|
||||
# Start a timer to reset the button state after 30 seconds
|
||||
self.reset_timer = Clock.schedule_once(self.reset_play_pause_state, 30)
|
||||
|
||||
# Toggle the state
|
||||
self.is_paused = not self.is_paused
|
||||
|
||||
def reset_play_pause_state(self, dt):
|
||||
"""Reset the play/pause button state to 'play' after 3 minutes."""
|
||||
# Reset the play/pause button state to 'play' after 30 seconds.
|
||||
Logger.info("Resetting play/pause button state to 'play' after timeout.")
|
||||
self.is_paused = False
|
||||
self.video_player.state = 'play'
|
||||
@@ -266,11 +289,12 @@ class MediaPlayer(Screen):
|
||||
Logger.info("Resuming image timer.")
|
||||
self.image_timer()
|
||||
|
||||
# Update the button appearance
|
||||
self.ids.play_pause_button.background_down = './Resurse/play.png'
|
||||
self.ids.play_pause_button.background_normal = './Resurse/play.png'
|
||||
|
||||
def check_playlist_updates(self, dt):
|
||||
"""Check for updates to the playlist."""
|
||||
#Check for updates to the playlist."""
|
||||
new_playlist = load_playlist() # Load the new playlist
|
||||
if new_playlist != self.playlist: # Compare the new playlist with the current one
|
||||
Logger.info("Playlist updated. Changes detected.")
|
||||
|
||||
@@ -8,9 +8,19 @@ CONFIG_FILE = './Resurse/app_config.txt'
|
||||
def load_config():
|
||||
"""Load configuration from app_config.txt."""
|
||||
if os.path.exists(CONFIG_FILE):
|
||||
with open(CONFIG_FILE, 'r') as file:
|
||||
Logger.info("python_functions: Configuration file loaded successfully.")
|
||||
return json.load(file)
|
||||
try:
|
||||
with open(CONFIG_FILE, 'r') as file:
|
||||
Logger.info("python_functions: Configuration file loaded successfully.")
|
||||
return json.load(file)
|
||||
except json.JSONDecodeError as e:
|
||||
Logger.error(f"python_functions: Failed to parse configuration file. Error: {e}")
|
||||
return {
|
||||
"screen_orientation": "Landscape",
|
||||
"screen_name": "",
|
||||
"quickconnect_key": "",
|
||||
"server_ip": "",
|
||||
"port": ""
|
||||
}
|
||||
else:
|
||||
Logger.error(f"python_functions: Configuration file {CONFIG_FILE} not found.")
|
||||
return {
|
||||
@@ -18,7 +28,7 @@ def load_config():
|
||||
"screen_name": "",
|
||||
"quickconnect_key": "",
|
||||
"server_ip": "",
|
||||
"port": ""
|
||||
"port": ""
|
||||
}
|
||||
|
||||
# Load configuration and initialize variables
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 446 KiB |
BIN
src/static/resurse/Office_audit_overview_5S-1.jpg
Normal file
BIN
src/static/resurse/Office_audit_overview_5S-1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 MiB |
BIN
src/static/resurse/Operational_Plan_FY25-1.jpg
Normal file
BIN
src/static/resurse/Operational_Plan_FY25-1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 MiB |
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 146 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 742 KiB |
Reference in New Issue
Block a user