【简易广告机】利用树莓派制作一个简易的广告机
上次我们安装了 omxplayer 这次我们进行shell编程,让play这个文件夹内的所有视频文件循环播放
废话少说,上shell代码
#!/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="./"
# you can normally leave this alone
SERVICE="omxplayer"
#无限循环当前目录的视频
while true
do
for entry in $VIDEOPATH/*
do
echo $entry;
sudo $SERVICE -o hdmi $entry
done
done
完成后把脚本文件放入视频文件所在的文件夹,然后赋予脚本可执行权限,执行:
pi@raspberrypi:~/pilearn/play $ chmod 777 play.sh
pi@raspberrypi:~/pilearn/play $ ./play.sh
.//gaobaiqiqiu.mp4
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Video codec omx-h264 width 720 height 480 profile 100 fps 24.000000
Audio codec aac channels 2 samplerate 48000 bitspersample 16
Subtitle count: 0, state: off, index: 1, delay: 0
V:PortSettingsChanged: 720x480@24.00 interlace:0 deinterlace:0 anaglyph:0 par:1.19 display:0 layer:0 alpha:255 aspectMode:0
不出意外的话,现在链接树莓派的显示器现在正在播放视频了
到这里,最为一个linux小白,该如何远程的把视频文件放入到树莓派的视频播放文件夹中呢?
那么该需要Linux应用编程了,鄙人对python一窍不通,对C语言颇感兴趣,那么就用C语言来编写网络编程吧 😃。
编程思想如下:
树莓派——客户端
电脑——服务端
设备心跳:
客户端 ——> 请求 ——> 服务端响应
音视频下载:
服务端 ——>下发 ——> 客户端响应
鄙人不才,只能做一成这么简易 😃