2013-05-09 63 views
1

我有this post以下bash腳本禮貌文件夾中的所有視頻:bash腳本來遍歷上Raspbian喘息

#!/bin/sh 

# get rid of the cursor so we don't see it when videos are running 
setterm -cursor off 

# set here the path to the directory containing your videos 
VIDEOPATH="/mnt/storage/videos" 

# you can normally leave this alone 
SERVICE="omxplayer" 

# now for our infinite loop! 
while true; do 
    if ps ax | grep -v grep | grep $SERVICE > /dev/null 
    then 
     sleep 1; 
    else 
     for entry in $VIDEOPATH/* 
     do 
      clear 
      omxplayer $entry > /dev/null 
     done 
    fi 
done 

我已經改變了呼叫omxplayer到全屏輸出聲音等等:

omxplayer -r -o hdmi $entry > /dev/null 

但即使在更改爲我的首選設置之前,該腳本似乎只會播放無限循環的文件夾中的第一個視頻。我已經檢查了視頻的許可權,並且它們與運行腳本的用戶擁有相同的權限。

+0

您是否嘗試過在循環中添加調試輸出? – Alfe 2013-05-09 20:55:34

+0

新人健忘,不,我沒有。我會嘗試一些調試。謝謝。 – mhollander38 2013-05-09 21:05:35

+0

當你說「只能播放文件夾中的第一個視頻」時,你的意思是「它重複播放第一個視頻」嗎? – 2013-05-09 21:06:59

回答

0

該腳本錯誤。我已經做了一些更新。看看是否適合你

#!/bin/sh 

# get rid of the cursor so we don't see it when videos are running 
setterm -cursor off 

# set here the path to the directory containing your videos 
VIDEOPATH="/mnt/storage/videos" 

# you can normally leave this alone 
SERVICE="omxplayer" 

for entry in $VIDEOPATH/* 
do 
    clear 
    $SERVICE $entry > /dev/null 

    while ps ax | grep -v grep | grep $SERVICE > /dev/null 
    do 
     sleep 5; 
    done 
done 
+0

這似乎沒有工作。當我回應文件名時,它只爲我一個。 – mhollander38 2013-05-10 22:07:54

+0

什麼不起作用?它播放任何視頻嗎?排除故障時刪除「>/dev/null」。 – 2013-05-10 23:43:39