Commit Graph

17 Commits

Author SHA1 Message Date
Kiwy Player
a8d6d70cd4 Fix duplicate cron jobs and enable systemd service
- Removed 6 duplicate cron entries that were spawning multiple instances
- Enabled systemd kiwy-player.service for proper startup management
- Service is now the single source of truth for app startup
- App runs stably with proper DISPLAY environment from systemd
2026-01-17 22:34:53 +02:00
Kiwy Player
e2abde9f9c DIAGNOSTIC: Disable background upload thread to test stability
Issue: Player crashes after 2-3 minutes during editing

Hypothesis: The background upload thread may be interfering with playback
even with the Clock.schedule_once fix.

Action: Temporarily disable the background upload to see if this is
the root cause of the crashes.

Edits will still be saved locally, just not uploaded to server during
this diagnostic test.

If player is stable without this thread, the issue is in the upload
logic or thread management.
2026-01-17 22:08:24 +02:00
Kiwy Player
a825d299bf CRITICAL FIX: Use Clock.schedule_once for thread-safe player state updates
BUG: Background upload thread was crashing the app

Problem:
  - _upload_to_server() runs in daemon thread
  - Was directly setting self.player.should_refresh_playlist from thread
  - Kivy is NOT thread-safe for direct state modifications
  - App crashed after 2-3 minutes during editing

Root cause:
  Line 503: self.player.should_refresh_playlist = True
  This directly modified Kivy object state from non-main thread
  Caused race conditions and memory corruption

Solution:
  - Use Clock.schedule_once() to schedule flag update on main thread
  - Ensures all Kivy state modifications happen on main thread
  - Thread-safe and proper Kivy API usage
  - No more app crashes during editing

This was causing the app to crash every 10-20 seconds during edits.
Should now be stable!
2026-01-17 22:05:56 +02:00
Kiwy Player
30f058182c Fix: Reload playlist after edited media is uploaded to server
CRITICAL FIX - This was the main issue preventing edited images from appearing!

Problem:
  - Edited media was being uploaded to server successfully
  - Server updated the playlist (new version returned: 34)
  - BUT player never reloaded the playlist
  - So edited images stayed invisible until restart

Solution:
1. EditPopup now sets should_refresh_playlist flag when upload succeeds
2. Main player checks this flag in check_playlist_and_play()
3. When flag is set, player immediately reloads playlist
4. Edited media appears instantly without needing restart

Testing:
  - Created diagnostic script test_edited_media_upload.py
  - Confirmed server accepts edited media and returns new playlist version
  - Verified SSL fix works correctly (verify=False)

Now edited images should appear immediately after save!
2026-01-17 22:01:13 +02:00
Kiwy Player
9b58f6b63d Fix: disable SSL verification for edited media server upload
Root cause identified from logs:
  [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate

The server uses a self-signed certificate (like production), but the edited media
upload endpoint was not disabling SSL verification while other API calls do.

Solution:
- Add verify=False to requests.post() call in _upload_to_server()
- Matches the SSL verification handling in get_playlists_v2.py
- Add warning about SSL verification being disabled
- Now edited images can upload successfully to server

This fixes the upload failures that were preventing edited images from being
synced to the server.
2026-01-17 21:53:07 +02:00
Kiwy Player
eeb2a61ef7 Fix image editing bug: ensure edits persist and upload correctly
Critical fixes for image editing workflow:

1. Keep local edited files as backup (don't delete after server upload)
   - Server may not process upload immediately
   - Keeps edits safe locally in case server fails
   - Prevents loss of edited images

2. Include original filename in metadata sent to server
   - Server needs to know which file was edited
   - Allows proper tracking and versioning

3. Improved error logging for server upload
   - Now logs detailed errors (404, 401, timeout, connection)
   - Shows clear messages when server doesn't support endpoint
   - Helps diagnose why edits aren't syncing to server

4. Better user feedback during save
   - Shows 'Saved to device' status first
   - Then 'Upload in progress' to show server sync happening
   - Clarifies local vs server save status

Bug symptoms fixed:
- Edited images now persist locally after restart
- Server upload now sends correct file information
- Clear error messages if server upload fails
- User understands 'local save' vs 'server sync' steps
2026-01-17 21:44:39 +02:00
Kiwy Player
d1382af517 updated sh files 2026-01-17 21:00:49 +02:00
Kiwy Player
6bf4e3735a Add comprehensive video playback optimization for smooth performance
Environment variable optimizations:
- KIVY_WINDOW='pygame' - Better window backend performance
- KIVY_AUDIO='ffpyplayer' - Optimized audio playback
- KIVY_GL_BACKEND='gl' - Use OpenGL for better graphics
- FFMPEG_THREADS='4' - Multi-threaded video decoding
- LIBPLAYER_BUFFER='2048000' - 2MB buffer for smooth playback
- SDL_AUDIODRIVER='alsa' - Better audio on Raspberry Pi

Kivy configuration optimizations:
- multisampling=0 - Disable for better performance
- fast_rgba=1 - Enable fast RGBA mode
- Stereo audio (channels=2)
- Reduced logging overhead (warning level)

Video widget enhancements:
- FFmpeg buffer optimization (2MB)
- Multi-threaded decoding (4 threads)
- Ignore index for better seeking
- Allow codec fallback
- 60 FPS animation delay

New video optimization script (.video-optimization.sh):
- GPU memory increased to 256MB
- Install video codec libraries
- Optimize swappiness to 30 (better memory management)
- CPU forced to performance mode
- Filesystem cache optimization

Installation integration:
- Runs video optimization automatically on Raspberry Pi
- Configures GPU memory, libraries, and system settings
- Improves overall video playback smoothness

This addresses video stuttering, frame drops, and playback lag
by optimizing at multiple levels: environment, application, and system.
2026-01-17 20:41:31 +02:00
Kiwy Player
e735e85d3c Add Wayland display server support for power management
Added support for both X11 and Wayland environments:

Display Server Detection:
- Auto-detects Wayland via WAYLAND_DISPLAY environment variable
- Falls back to X11 commands if not Wayland
- Works seamlessly on both display servers

Wayland-specific tools:
- wlopm - Wayland output power management (keeps display on)
- wlr-randr - Output management for wlroots compositors
- ydotool - Mouse movement for Wayland (alternative to xdotool)
- systemd-inhibit integration for idle prevention

Enhanced display keep-alive script:
- Detects display server type on startup
- Uses appropriate commands based on environment
- Wayland: wlopm, wlr-randr, ydotool
- X11: xset, xdotool, xrandr
- Both: tvservice for HDMI power control

App-level improvements (main.py):
- Detects Wayland via os.environ check
- Executes Wayland-specific commands when detected
- Maintains X11 compatibility for older systems

Installation improvements:
- Auto-installs Wayland tools if Wayland is detected
- Attempts to install: wlopm, wlr-randr, ydotool
- Graceful fallback if packages unavailable

This ensures HDMI power management works correctly on:
- Raspberry Pi OS with X11 (older versions)
- Raspberry Pi OS with Wayland (Bookworm and newer)
- Any Linux system using either display server
2026-01-17 20:15:47 +02:00
Kiwy Player
72a6d7e704 Add aggressive HDMI power control to prevent display shutdown
Enhanced Raspberry Pi HDMI power management:

Boot Configuration (/boot/config.txt):
- hdmi_blanking=0 - Disable HDMI blanking
- hdmi_force_hotplug=1 - Force HDMI mode always on
- hdmi_ignore_cec_init=1 - Disable HDMI CEC interference
- hdmi_ignore_edid=0xa5000080 - Disable HDMI sleep mode

New systemd services:
- hdmi-poweron.service - Runs tvservice -p every 30 seconds
- screen-keepalive.service - Aggressive display keep-alive script

Display keep-alive script (.display-keepalive.sh):
- tvservice -p - Force HDMI to stay powered
- xset commands - Keep X11 screensaver off
- xdotool - Mouse movement for activity detection
- xrandr - Disable monitor power profile saving
- 30-second loop for continuous power signaling

Enhanced app-level control (main.py):
- DISPLAY=:0 environment variable for X11 commands
- tvservice integration in signal_screen_activity()
- xrandr power profile management
- More aggressive DPMS disabling

This addresses HDMI being powered down at multiple levels:
1. Firmware level (boot config)
2. System level (systemd services)
3. X11 level (xset, xdotool, xrandr)
4. App level (continuous signaling)

HDMI output should now remain powered throughout playback.
2026-01-17 19:59:45 +02:00
Kiwy Player
8703350b23 Add screen activity signaler to prevent display sleep
- Added signal_screen_activity() method to SignagePlayer class
- Runs every 20 seconds automatically
- Also triggered on any touch/user input events

Multiple methods used to keep display awake:
- xset s reset - Resets screensaver timer
- xset dpms force on - Forces display on
- xdotool - Subtle mouse movement to trigger activity

This complements the system-level power management:
- Works alongside display power management settings
- Non-blocking and non-critical (fails gracefully)
- Signals every 20 seconds + on user input
- Prevents display from sleeping during playback

Screen should now remain active throughout media playback.
2026-01-17 19:23:15 +02:00
Kiwy Player
17ae5439bd Add screen keep-alive functionality to prevent display sleep
- Created .keep-screen-alive.sh wrapper script with multiple methods:
  * systemd-inhibit (primary - prevents OS-level sleep/suspend)
  * xset commands (prevents X11 screensaver)
  * Mouse movement (prevents idle timeout)

- Added screen-keepalive.service systemd unit:
  * Runs xset s reset every 30 seconds
  * Auto-restarts on failure
  * Integrated with graphical session

- Multiple layers of screen protection:
  * HDMI blanking disabled
  * CPU power saving disabled
  * System sleep/suspend disabled
  * X11 screensaver disabled
  * DPMS (Display Power Management) disabled
  * Display forced on periodically

Screen will now remain active while player is running, preventing lockups or blank screens during playback.
2026-01-17 19:02:00 +02:00
Kiwy Player
81432ac832 Add autostart functionality and power management for Raspberry Pi
- Enhanced install.sh with comprehensive autostart workflow:
  * XDG autostart entry (desktop environment)
  * systemd user service (most reliable)
  * LXDE autostart support (Raspberry Pi OS)
  * Cron fallback (@reboot)
  * Terminal mode enabled for debugging

- Added Raspberry Pi power management features:
  * Disable HDMI screen blanking
  * Prevent CPU power saving (performance mode)
  * Disable system sleep/suspend
  * X11 screensaver disabled
  * Display power management (DPMS) disabled

- Fixed sudo compatibility:
  * Properly detects actual user when run with sudo
  * Correct file ownership for user configs
  * systemctl --user works correctly

- Player launches in terminal for error visibility
- Autostart configured to use start.sh (watchdog with auto-restart)
2026-01-17 18:50:47 +02:00
Kiwy Signage Player
46d9fcf6e3 delete watch dog 2025-12-08 21:52:13 +02:00
Kiwy Signage Player
f1a84d05d5 updated buttons in settings 2025-12-08 21:52:03 +02:00
Kiwy Signage Player
f573af0505 update 2025-12-05 00:36:38 +02:00
744681bb20 update player with wachdog and intro 2025-11-22 10:26:20 +02:00