updated to final version

This commit is contained in:
2025-05-14 16:03:50 +03:00
parent 9e92f82a1c
commit 8e91d58573
4 changed files with 303 additions and 100 deletions

84
How to use.txt Normal file
View File

@@ -0,0 +1,84 @@
Here is the complete content for the `How to use.txt` file, starting from **point 3** and including all the missing information:
```plaintext
### How to Install, Start, and Use the Signage Player Application
This guide provides step-by-step instructions for installing, starting, and using the signage player application.
---
## 3. Using the Application
### MediaPlayer Screen
- **Play/Pause Button**:
- Toggles between playing and pausing the media.
- Automatically resumes playback after 30 seconds if not toggled again.
- **Next/Previous Buttons**:
- Navigate to the next or previous media in the playlist.
- **Exit App Button**:
- Opens a password-protected popup. Enter the `quickconnect_key` from the configuration file to exit the app.
### Settings Screen
- **Configuration Fields**:
- Update fields like `screen_orientation`, `screen_name`, `quickconnect_key`, `server_ip`, and `port`.
- **Save Button**:
- Saves the updated configuration and returns to the MediaPlayer screen.
- **Exit App Button**:
- Opens a password-protected popup. Enter the `quickconnect_key` to exit the app.
---
## 4. Configuration
### Configuration File
The configuration file is located at:
```bash
app_config.txt
```
### Example Configuration
```json
{
"screen_orientation": "Landscape",
"screen_name": "MyScreen",
"quickconnect_key": "12345",
"server_ip": "192.168.1.1",
"port": "8080"
}
```
### Updating Configuration
1. Navigate to the **Settings Screen** in the app.
2. Update the fields and click **Save**.
3. The configuration will be saved to `app_config.txt`.
---
## 5. Troubleshooting
### Permission Denied for `run_app.sh`
- Ensure the script is executable:
```bash
chmod +x /home/pi/Desktop/signage-player/run_app.sh
```
### Application Does Not Start on Boot
- Verify the `~/.bashrc` or `crontab` entry is correct.
- Check the script's permissions and paths.
### Media Files Not Playing
- Ensure media files are downloaded to the correct directory:
```bash
/home/pi/Desktop/signage-player/src/static/resurse
```
- Check the playlist configuration and server connection.
### Password for Exit App
- The password is the `quickconnect_key` from the configuration file (`app_config.txt`).
---
Let me know if you need further clarification or additional details!
```

202
README.md
View File

@@ -1,62 +1,194 @@
# Kivy Media Player
This project is a media player application built using Kivy. It allows users to play video files, display images, and manage settings for quick connect codes and server configurations. The application checks for updates to the playlist every five minutes while running in full screen. ```markdown
# 🎥 Kivy Media Player
## Project Structure A media player application built using **Kivy** that allows users to play video files, display images, and manage settings for quick connect codes and server configurations. The application checks for updates to the playlist every five minutes while running in full-screen mode.
---
## 📂 Project Structure
``` ```
kivy-media-player signage-player
├── src ├── src
│ ├── main.py # Entry point of the Kivy application
│ ├── settings.py # Manages the settings page
│ ├── media_player.py # Handles media playback │ ├── media_player.py # Handles media playback
│ ├── utils.py # Utility functions for downloading files and updating playlists │ ├── python_functions.py # Utility functions for downloading files and updating playlists
│ ├── kv │ ├── kv
│ │ ├── main.kv # Layout for the main application window
│ │ ├── settings.kv # Layout for the settings page
│ │ └── media_player.kv # Layout for the media player screen │ │ └── media_player.kv # Layout for the media player screen
── assets ── Resurse
├── images # Directory for image files ├── app_config.txt # Configuration file
── videos # Directory for video files ── log.txt # Log file for media events
│ │ ├── play.png # Play button icon
│ │ ├── pause.png # Pause button icon
│ │ └── other icons... # Additional icons for the UI
│ └── static
│ └── resurse # Directory for media files (images/videos)
├── requirements.txt # Project dependencies ├── requirements.txt # Project dependencies
├── run_app.sh # Script to run the application
├── install.sh # Installation script
├── How to use.txt # Detailed usage instructions
└── README.md # Documentation for the project └── README.md # Documentation for the project
``` ```
## Setup Instructions ---
1. Clone the repository: ## 🚀 Setup Instructions
```
git clone <repository-url> ### Prerequisites
cd kivy-media-player Before installing the application, ensure the following are installed on your Raspberry Pi:
- **Python 3.7 or higher**
- **pip3** (Python package manager)
- **ffmpeg** (for video conversion)
- **Internet connection** for downloading dependencies
### Installation Steps
1. **Clone the Repository**
```bash
git clone https://gitea.moto-adv.com/ske087/signage-player.git
cd signage-player
``` ```
2. Install the required dependencies: 2. **Run the Installation Script**
``` ```bash
pip install -r requirements.txt ./install.sh
``` ```
3. Run the application: The installation script will:
``` - Update the system.
python src/main.py - Install required Python and system dependencies.
- Clone the repository to `/home/pi/Desktop/ds-player`.
- Add the run_app.sh script to `~/.bashrc` for autostart.
- Make the run_app.sh script executable.
3. **Reboot the Device**
After installation, reboot the Raspberry Pi to start the application automatically:
```bash
sudo reboot
``` ```
## Usage Guidelines ---
- Upon launching the application, users can navigate to the settings page to enter their quick connect code and server IP/domain. ## 🎮 How to Use
- The media player screen allows users to view images and play videos from the playlist.
- The application automatically checks for updates to the playlist every five minutes.
## Contributing ### MediaPlayer Screen
- **▶️ Play/Pause Button**:
- Toggles between playing and pausing the media.
- Automatically resumes playback after 30 seconds if not toggled again.
- **⏩ Next/⏪ Previous Buttons**:
- Navigate to the next or previous media in the playlist.
- **❌ Exit App Button**:
- Opens a password-protected popup. Enter the `quickconnect_key` from the configuration file to exit the app.
### Settings Screen
- **Configuration Fields**:
- Update fields like `screen_orientation`, `screen_name`, `quickconnect_key`, `server_ip`, and `port`.
- **💾 Save Button**:
- Saves the updated configuration and returns to the MediaPlayer screen.
- **❌ Exit App Button**:
- Opens a password-protected popup. Enter the `quickconnect_key` to exit the app.
---
## ⚙️ Configuration
### Configuration File
The configuration file is located at:
```bash
/home/pi/Desktop/signage-player/src/Resurse/app_config.txt
```
### Example Configuration
```json
{
"screen_orientation": "Landscape",
"screen_name": "tv-panou1",
"quickconnect_key": "8887779",
"server_ip": "172.20.10.9",
"port": "80"
}
```
### Updating Configuration
1. Navigate to the **Settings Screen** in the app.
2. Update the fields and click **Save**.
3. The configuration will be saved to app_config.txt.
---
## 🛠️ Troubleshooting
### Permission Denied for run_app.sh
- Ensure the script is executable:
```bash
chmod +x /home/pi/Desktop/signage-player/run_app.sh
```
### Application Does Not Start on Boot
- Verify the `~/.bashrc` entry is correct.
- Check the script's permissions and paths.
### Media Files Not Playing
- Ensure media files are downloaded to the correct directory:
```bash
/home/pi/Desktop/signage-player/src/static/resurse
```
- Check the playlist configuration and server connection.
### Password for Exit App
- The password is the `quickconnect_key` from the configuration file (`app_config.txt`).
---
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a pull request or open an issue for any suggestions or improvements. Contributions are welcome! Please feel free to submit a pull request or open an issue for any suggestions or improvements.
## License ---
This project is licensed under the MIT License. See the LICENSE file for more details. ## 📜 License
install the requirements for fpyplayer This project is licensed under the **MIT License**. See the `LICENSE` file for more details.
```
sudo apt-get update ---
sudo apt-get install libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev
sudo apt-get install libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev libswscale-dev libswresample-dev libpostproc-dev ### Improvements Made:
pip install ffpyplayer 1. **Added Emojis**:
- Emojis are used to make the sections visually appealing and easier to navigate.
2. **Improved Formatting**:
- Added proper headings, subheadings, and code blocks for better readability.
3. **Enhanced "How to Use" Section**:
- Added icons to represent buttons and actions.
4. **Troubleshooting Section**:
- Clearly outlined common issues and their solutions.
5. **Contributing and License Sections**:
- Added a friendly note for contributors and a license section.
---
Let me know if you need further adjustments or additional sections!---
### Improvements Made:
1. **Added Emojis**:
- Emojis are used to make the sections visually appealing and easier to navigate.
2. **Improved Formatting**:
- Added proper headings, subheadings, and code blocks for better readability.
3. **Enhanced "How to Use" Section**:
- Added icons to represent buttons and actions.
4. **Troubleshooting Section**:
- Clearly outlined common issues and their solutions.
5. **Contributing and License Sections**:
- Added a friendly note for contributors and a license section.
---
Let me know if you need further adjustments or additional sections!

View File

@@ -3,8 +3,7 @@
# Define variables # Define variables
REPO_URL="https://gitea.moto-adv.com/ske087/signage-player.git" # Replace with your Gitea repository URL REPO_URL="https://gitea.moto-adv.com/ske087/signage-player.git" # Replace with your Gitea repository URL
PROJECT_DIR="/home/pi/Desktop/ds-player" # Full path to the installation folder PROJECT_DIR="/home/pi/Desktop/ds-player" # Full path to the installation folder
VENV_DIR="$PROJECT_DIR/venv" # Path to the virtual environment RUN_SCRIPT="$PROJECT_DIR/run_app.sh" # Path to the run_app.sh script
SERVICE_NAME="ds-player.service"
# Step 0: Check if an internet connection exists # Step 0: Check if an internet connection exists
echo "Checking internet connection..." echo "Checking internet connection..."
@@ -18,80 +17,51 @@ fi
# Step 1: Check if the installation folder exists # Step 1: Check if the installation folder exists
if [ -d "$PROJECT_DIR" ]; then if [ -d "$PROJECT_DIR" ]; then
echo "Installation folder already exists: $PROJECT_DIR" echo "Installation folder already exists: $PROJECT_DIR"
echo "Skipping installation steps and starting the service..." echo "Skipping installation steps..."
sudo systemctl start "$SERVICE_NAME" else
echo "Service started successfully!" # Step 2: Update the system
exit 0 echo "Updating the system..."
sudo apt-get update -y
sudo apt-get upgrade -y
# Step 3: Clone the repository
echo "Cloning the repository from $REPO_URL..."
git clone "$REPO_URL" "$PROJECT_DIR"
# Step 4: Set permissions for the project directory
echo "Setting permissions for the project directory to 0777..."
sudo chmod -R 0777 "$PROJECT_DIR"
fi fi
# Step 2: Update the system
echo "Updating the system..."
sudo apt-get update -y
sudo apt-get upgrade -y
# Step 3: Clone the repository
echo "Cloning the repository from $REPO_URL..."
git clone "$REPO_URL" "$PROJECT_DIR"
# Step 4: Set permissions for the project directory
echo "Setting permissions for the project directory to 0777..."
sudo chmod -R 0777 "$PROJECT_DIR"
# Step 5: Navigate to the project directory # Step 5: Navigate to the project directory
cd "$PROJECT_DIR" || { echo "Failed to navigate to project directory."; exit 1; } cd "$PROJECT_DIR" || { echo "Failed to navigate to project directory."; exit 1; }
# Step 6: Install Python virtual environment tools # Step 6: Install Python dependencies
echo "Installing Python virtual environment tools..." echo "Installing Python dependencies..."
sudo apt-get install -y python3-venv python3-pip sudo apt-get install -y python3-pip
pip3 install --upgrade pip
pip3 install -r requirements.txt --break-system-packages
# Step 7: Create a virtual environment # Step 7: Install system dependencies for ffpyplayer
echo "Creating a Python virtual environment in $VENV_DIR..."
python3 -m venv "$VENV_DIR"
# Step 8: Activate the virtual environment and install dependencies
echo "Activating the virtual environment and installing dependencies..."
source "$VENV_DIR/bin/activate"
pip install --upgrade pip
pip install -r requirements.txt
# Step 9: Install system dependencies for ffpyplayer
echo "Installing system dependencies for ffpyplayer..." echo "Installing system dependencies for ffpyplayer..."
sudo apt-get install -y libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev \ sudo apt-get install -y libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev \
libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev libswscale-dev libswresample-dev libpostproc-dev \ libavcodec-dev libavformat-dev libavdevice-dev libavutil-dev libswscale-dev libswresample-dev libpostproc-dev \
libavcodec-extra libavdevice-dev libavfilter-dev libavcodec-extra libavdevice-dev libavfilter-dev
# Step 10: Install ffpyplayer in the virtual environment # Step 8: Add run_app.sh to ~/.bashrc for autostart
echo "Installing ffpyplayer in the virtual environment..." echo "Adding $RUN_SCRIPT to ~/.bashrc for autostart..."
pip install ffpyplayer if ! grep -Fxq "$RUN_SCRIPT" ~/.bashrc; then
echo "$RUN_SCRIPT" >> ~/.bashrc
echo "Added $RUN_SCRIPT to ~/.bashrc."
else
echo "$RUN_SCRIPT is already in ~/.bashrc."
fi
# Step 11: Create a systemd service for autostart # Step 9: Make run_app.sh executable
echo "Creating systemd service for autostart..." echo "Making $RUN_SCRIPT executable..."
SERVICE_FILE="/etc/systemd/system/$SERVICE_NAME" chmod +x "$RUN_SCRIPT"
sudo bash -c "cat > $SERVICE_FILE" <<EOL
[Unit]
Description=Kivy Media Player
After=network.target
[Service] # Step 10: Confirm installation
ExecStart=$VENV_DIR/bin/python3 $PROJECT_DIR/src/main.py
WorkingDirectory=$PROJECT_DIR
Restart=always
User=pi
Environment=DISPLAY=:0
Environment=XAUTHORITY=/home/pi/.Xauthority
[Install]
WantedBy=multi-user.target
EOL
# Step 12: Enable and start the service
echo "Enabling and starting the systemd service..."
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
sudo systemctl start "$SERVICE_NAME"
# Step 13: Confirm installation
echo "Installation completed successfully!" echo "Installation completed successfully!"
echo "The application will now start automatically on boot." echo "The application will now start automatically when the device starts."
echo "You can manually start it using: sudo systemctl start $SERVICE_NAME" echo "You can manually run the application using: $RUN_SCRIPT"
echo "You can check its status using: sudo systemctl status $SERVICE_NAME"

17
run_app.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/bash
# filepath: /home/pi/Desktop/signage-player/run_app.sh
# Navigate to the application directory
cd /home/pi/Desktop/signage-player/src || exit
# Check for the --verbose flag
if [[ "$1" == "--verbose" ]]; then
# Run the application with terminal output
echo "Starting the application with terminal output..."
python3 media_player.py
else
# Run the application and suppress terminal output
echo "Starting the application without terminal output..."
python3 media_player.py > /dev/null 2>&1 &
fi