I am working on a simple video player, where a user can upload and play or stop a video. From command line it works just fine. However, from the page it does not appear to start the video.
Device is CM4, and its running pi os lite 32
This is the php that calls the command to run the videoPlayer.sh script.
start-player-form.php:videoPlayer.sh I can run from command line with The video plays just fine:
videoPlayer.sh
-rwxrwxrwx 1 pi www-data 758 Feb 23 21:35 videoPlayer.sh
-rwxrwxrwx 1 pi www-data 1076 Feb 23 21:35 start-player-form.php
drwxrwxrwx 2 pi www-data 4096 Feb 23 21:07 videos
Some similar unresolved posts i found:
https://ubuntuforums.org/showthread.php?t=2170458
https://raspberrypi.stackexchange.com/q ... m-php-file
Device is CM4, and its running pi os lite 32
This is the php that calls the command to run the videoPlayer.sh script.
start-player-form.php:
Code:
<?phpinclude "../includes/console-log.php";console_log("start-player-form.php connected");console_log($_POST['videoToPlay']);console_log($_POST['loopVideo']);$videoToPlay = substr($_POST['videoToPlay'], strrpos($_POST['videoToPlay'], "\\"));console_log($videoToPlay);if ($_POST['videoToPlay'] == "Choose...") { echo '<div class="alert alert-warning alert-dismissible fade show" role="alert"> No video file is selected. <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </div>';} else { console_log("start-player-form.php function executed"); $startPlayer = escapeshellcmd("sh ../commands/videoPlayer.sh start '" . $videoToPlay . "' '" . $_POST['loopVideo'] . "'"); $startPlayerOutput = shell_exec($startPlayer); echo '<div class="alert alert-success alert-dismissible fade show" role="alert"> ' . $startPlayerOutput . ' <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> </div>';}
Code:
sh /var/www/html/commands/videoPlayer.sh start big* false
videoPlayer.sh
Code:
#!/bin/bashecho "Digital Signage Video Player Starting..."#find vlcvar=$(ps -ef | grep vlc | grep -v grep | awk '{print $2}')action=$1fileName=$2videoLoop=$3#default path to video upload folderpath="/var/www/html/videos/"#play video to HDMI, loopedplayAndLoop="vlc --loop --fullscreen ${path}${fileName}"#play video to HDMI, not loopedplayAndExit="vlc --play-and-exit --fullscreen ${path}${fileName}"if [ "$action" = 'start' ]; then if [ "$videoLoop" = 'true' ]; then echo "Playing Video, Loop = true" $playAndLoop fi if [ "$videoLoop" = 'false' ]; then echo "Playing Video, Loop = false" $playAndExit fifiif [ "$action" = 'stop' ]; then echo "Stopping Video" sudo kill $varfi
Permissions:VLC media player 3.0.20 Vetinari
Command Line Interface initialized. Type `help' for help.
> Shutting down.
-rwxrwxrwx 1 pi www-data 758 Feb 23 21:35 videoPlayer.sh
-rwxrwxrwx 1 pi www-data 1076 Feb 23 21:35 start-player-form.php
drwxrwxrwx 2 pi www-data 4096 Feb 23 21:07 videos
Some similar unresolved posts i found:
https://ubuntuforums.org/showthread.php?t=2170458
https://raspberrypi.stackexchange.com/q ... m-php-file
Statistics: Posted by xha1e — Fri Feb 23, 2024 9:39 pm