added buttons
|
Before Width: | Height: | Size: 36 KiB |
BIN
src/Resurse/left-arrow-blue.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
src/Resurse/left-arrow-green.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
9289
src/Resurse/log.txt
BIN
src/Resurse/pause.png
Normal file
|
After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 112 KiB |
BIN
src/Resurse/play.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 36 KiB |
BIN
src/Resurse/right-arrow-blue.png
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
src/Resurse/right-arrow-green.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
src/__pycache__/python_functions.cpython-311.pyc
Normal file
@@ -18,17 +18,58 @@
|
|||||||
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
|
pos_hint: {'center_x': 0.5, 'center_y': 0.5}
|
||||||
opacity: 0
|
opacity: 0
|
||||||
|
|
||||||
|
# Settings (Home) button
|
||||||
Button:
|
Button:
|
||||||
id: settings_button
|
id: settings_button
|
||||||
size_hint: None, None
|
size_hint: None, None
|
||||||
size: 90, 90
|
size: 75, 75
|
||||||
pos_hint: {'right': 0.98, 'bottom': 0.98}
|
pos_hint: {'right': 0.98, 'bottom': 0.98}
|
||||||
background_normal: './Resurse/home_icon.png'
|
background_normal: './Resurse/home_icon.png'
|
||||||
background_down: './Resurse/home_icon.png'
|
background_down: './Resurse/home_icon.png'
|
||||||
background_color: 10/255.0, 160/255.0, 255/255.0, 0.80
|
background_color: 1, 1, 1, 0.9 # Temporary red background for debugging
|
||||||
|
border: [0, 0, 0, 0] # Remove the default border
|
||||||
opacity: 1
|
opacity: 1
|
||||||
on_release: app.open_settings()
|
on_release: app.open_settings()
|
||||||
|
|
||||||
|
# Right Arrow button
|
||||||
|
Button:
|
||||||
|
id: right_arrow_button
|
||||||
|
size_hint: None, None
|
||||||
|
size: 75, 75
|
||||||
|
pos_hint: {'right': 0.93, 'bottom': 0.98}
|
||||||
|
background_normal: './Resurse/left-arrow-blue.png'
|
||||||
|
background_down: './Resurse/left-arrow-green.png'
|
||||||
|
background_color: 1, 1, 1, 0.9 # Temporary green background for debugging
|
||||||
|
border: [0, 0, 0, 0] # Remove the default border
|
||||||
|
opacity: 1
|
||||||
|
on_release: root.next_media(None)
|
||||||
|
|
||||||
|
# Play/Pause button
|
||||||
|
Button:
|
||||||
|
id: play_pause_button
|
||||||
|
size_hint: None, None
|
||||||
|
size: 75, 75
|
||||||
|
pos_hint: {'right': 0.88, 'bottom': 0.98}
|
||||||
|
background_normal: './Resurse/play.png'
|
||||||
|
background_down: './Resurse/pause.png'
|
||||||
|
background_color: 1, 1, 1, 0.9 # Temporary blue background for debugging
|
||||||
|
border: [0, 0, 0, 0] # Remove the default border
|
||||||
|
opacity: 1
|
||||||
|
on_press: root.toggle_play_pause()
|
||||||
|
|
||||||
|
# Left Arrow button
|
||||||
|
Button:
|
||||||
|
id: left_arrow_button
|
||||||
|
size_hint: None, None
|
||||||
|
size: 75, 75
|
||||||
|
pos_hint: {'right': 0.83, 'bottom': 0.98}
|
||||||
|
background_normal: './Resurse/right-arrow-blue.png'
|
||||||
|
background_down: './Resurse/right-arrow-green.png'
|
||||||
|
background_color: 1, 1, 1, 0.9 # Temporary yellow background for debugging
|
||||||
|
border: [0, 0, 0, 0] # Remove the default border
|
||||||
|
opacity: 1
|
||||||
|
on_release: root.previous_media()
|
||||||
|
|
||||||
<SettingsScreen>:
|
<SettingsScreen>:
|
||||||
BoxLayout:
|
BoxLayout:
|
||||||
orientation: 'vertical'
|
orientation: 'vertical'
|
||||||
|
|||||||
@@ -33,26 +33,37 @@ class MediaPlayer(Screen):
|
|||||||
self.video_player = self.ids.video_player # Reference to the Video widget
|
self.video_player = self.ids.video_player # Reference to the Video widget
|
||||||
self.image_display = self.ids.image_display # Reference to the Image widget
|
self.image_display = self.ids.image_display # Reference to the Image widget
|
||||||
self.log_file = os.path.join(os.path.dirname(__file__), 'Resurse', 'log.txt') # Path to the log file
|
self.log_file = os.path.join(os.path.dirname(__file__), 'Resurse', 'log.txt') # Path to the log file
|
||||||
|
self.is_paused = False # Track the state of the play/pause button
|
||||||
|
|
||||||
# Schedule periodic updates to check for playlist updates
|
# Schedule periodic updates to check for playlist updates
|
||||||
Clock.schedule_interval(self.check_playlist_updates, 300) # Every 5 minutes
|
Clock.schedule_interval(self.check_playlist_updates, 300) # Every 5 minutes
|
||||||
# Bind key events to handle fullscreen toggle
|
# Bind key events to handle fullscreen toggle
|
||||||
Window.bind(on_key_down=self.on_key_down)
|
Window.bind(on_key_down=self.on_key_down)
|
||||||
|
|
||||||
# Start a timer to hide the settings button after 10 seconds
|
# Start a timer to hide the buttons after 10 seconds
|
||||||
self.hide_button_timer = Clock.schedule_once(self.hide_settings_button, 10)
|
self.hide_button_timer = Clock.schedule_once(self.hide_buttons, 10)
|
||||||
|
|
||||||
def on_touch_down(self, touch):
|
def on_touch_down(self, touch):
|
||||||
"""Handle touch events to reset the settings button visibility."""
|
"""Handle touch events to reset the button visibility."""
|
||||||
self.ids.settings_button.opacity = 1 # Make the settings button visible
|
self.show_buttons() # Make all buttons visible
|
||||||
if hasattr(self, 'hide_button_timer'):
|
if hasattr(self, 'hide_button_timer'):
|
||||||
Clock.unschedule(self.hide_button_timer) # Cancel the existing hide timer
|
Clock.unschedule(self.hide_button_timer) # Cancel the existing hide timer
|
||||||
self.hide_button_timer = Clock.schedule_once(self.hide_settings_button, 10) # Restart the hide timer
|
self.hide_button_timer = Clock.schedule_once(self.hide_buttons, 10) # Restart the hide timer
|
||||||
return super(MediaPlayer, self).on_touch_down(touch)
|
return super(MediaPlayer, self).on_touch_down(touch)
|
||||||
|
|
||||||
def hide_settings_button(self, *args):
|
def hide_buttons(self, *args):
|
||||||
"""Hide the settings button after inactivity."""
|
"""Hide all buttons after inactivity."""
|
||||||
self.ids.settings_button.opacity = 0
|
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."""
|
||||||
|
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):
|
def on_key_down(self, window, key, *args):
|
||||||
"""Handle key events for toggling fullscreen mode."""
|
"""Handle key events for toggling fullscreen mode."""
|
||||||
@@ -65,6 +76,7 @@ class MediaPlayer(Screen):
|
|||||||
download_media_files(self.playlist) # Download media files from 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
|
clean_unused_files(self.playlist) # Remove unused files from the resource folder
|
||||||
self.play_media() # Start playing media
|
self.play_media() # Start playing media
|
||||||
|
self.show_buttons() # Ensure buttons are visible when the screen is entered
|
||||||
|
|
||||||
def log_event(self, file_name, event):
|
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."""
|
||||||
@@ -182,15 +194,33 @@ class MediaPlayer(Screen):
|
|||||||
# Schedule the next media after the duration
|
# Schedule the next media after the duration
|
||||||
Clock.schedule_once(self.next_media, duration)
|
Clock.schedule_once(self.next_media, duration)
|
||||||
|
|
||||||
def next_media(self, dt):
|
def next_media(self, dt=None):
|
||||||
"""Move to the next media in the playlist."""
|
"""Move to the next media in the playlist."""
|
||||||
# Log the stop of the current media
|
Logger.info("Navigating to the next media.")
|
||||||
current_media = self.playlist[self.current_index].get('file_name', '')
|
self.current_index = (self.current_index + 1) % len(self.playlist)
|
||||||
self.log_event(current_media, "STOPPED")
|
self.play_media()
|
||||||
|
|
||||||
# Move to the next media
|
def previous_media(self):
|
||||||
self.current_index = (self.current_index + 1) % len(self.playlist) # Increment the index
|
"""Go to the previous media in the playlist."""
|
||||||
self.play_media() # Play the next media
|
Logger.info("Navigating to the previous media.")
|
||||||
|
self.current_index = (self.current_index - 1) % len(self.playlist)
|
||||||
|
self.play_media()
|
||||||
|
|
||||||
|
def toggle_play_pause(self):
|
||||||
|
"""Toggle the play/pause button state and update its appearance."""
|
||||||
|
if self.is_paused:
|
||||||
|
Logger.info("Resuming media playback.")
|
||||||
|
self.video_player.state = 'play'
|
||||||
|
# Update the button to indicate the playing state
|
||||||
|
self.ids.play_pause_button.background_down = './Resurse/play.png'
|
||||||
|
else:
|
||||||
|
Logger.info("Pausing media playback.")
|
||||||
|
self.video_player.state = 'pause'
|
||||||
|
# Update the button to indicate the paused state
|
||||||
|
self.ids.play_pause_button.background_down = './Resurse/pause.png'
|
||||||
|
|
||||||
|
# Toggle the state
|
||||||
|
self.is_paused = not self.is_paused
|
||||||
|
|
||||||
def check_playlist_updates(self, dt):
|
def check_playlist_updates(self, dt):
|
||||||
"""Check for updates to the playlist."""
|
"""Check for updates to the playlist."""
|
||||||
|
|||||||