Linux下HTML5播放器一键生成脚本

2017年02月7日

原创内容,转载请注明出处: https://www.myzhenai.com.cn/post/2394.html https://www.myzhenai.com/thread-17969-1-1.html
关键词: Linux Shell HTML5 播放器 脚本
我使用的Html5播放器代码是扒 https://www.hzyxc.com/tech/yxcmusic/ 这家的, 他在hostloc上开源的.
我只是写了一个一键生成网页的脚本, 大家如果是Linux服务器的, 并且音频文件也保存在服务器上,那么就可以用这个脚本生成一个网页链接, 然后发布这个网页就可以了.
目录下的几个文件夹和文件
alb —存放播放器图标
images —存放播放器背景图片和播放器界面图片, 背景图片需要以bg+数字开头的文件名
js — 存放播放器的js文件
music — 我本地演示的一些音乐文件
bot.log — html5播放器网页底部份文件
music.sh — 播放器链接生成脚本, 会生成一个 in.log文件
top.log — html5播放器网页头部文件
player.html — 生成的播放器网页文件

#!/usr/bin/env bash
##############################################################################################################################################
# This is Musice HTML5 Player Script
# Author: RucLinux 海南胡说 海南仙岛
# Website: www.myzhenai.com www.myzhenai.com.cn www.haikou-china.com jiayu.mybabya.com www.0898-shop.com
##############################################################################################################################################
p="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
#two instance
############################################################################################################
function one_find() (
if [ -z "${2}" ]; then
for file in `find ${1}`
                do
               if [ -f "${file}" ]; then
               f=`echo $file | awk -F "/" '{ print $NF }' | awk -F "." '{ print $1 }'`
               one="			{\n"
               two="				title : "
               three="				singer :"
               four="				cover  :"
               fives="				src    : "
               six="			},\r"
               echo -e "${one}${two}'${f}',\r${three}'${f}',\r${four}'alb/biaoti.png',\r${fives}'${file}'\r${six}" >> ${p}/in.log
               fi
                done

else
for file in `find ${1} -name *.${2}`
                do
               if [ -f "${file}" ]; then
               f=`echo $file | awk -F "/" '{ print $NF }' | awk -F "." '{ print $1 }'`
               one="			{\n"
               two="				title : "
               three="				singer :"
               four="				cover  :"
               fives="				src    : "
               six="			},\r"
               echo -e "${one}${two}'${f}',\r${three}'${f}',\r${four}'alb/biaoti.png',\r${fives}'${file}'\r${six}" >> ${p}/in.log
               fi
                done
fi
)
############################################################################################################
one_find $1 $2
cat ${p}/top.log ${p}/in.log ${p}/bot.log > ${p}/player.html
chmod 777 ${p}/player.html

 
脚本使用方法

#sh music.sh part mp3
OR
#sh music.sh part

 
part是要搜索的路径, mp3是要搜索的文件后缀名 如果第二个参数留空,会搜索路径下的所有文件
源码及演示文件下载 链接: https://pan.baidu.com/s/1hrGsL5i 密码: f37d

演示地址 https://jiayu.mybabya.com/player.html


sicnature ---------------------------------------------------------------------
Your current IP address is: 44.200.49.193
Your IP address location: 美国弗吉尼亚阿什本
Your IP address country and region: 美国 美国
Your current browser is:
Your current system is:
Original content, please indicate the source:
同福客栈论坛 | 蟒蛇科普海南乡情论坛 | JiaYu Blog
sicnature ---------------------------------------------------------------------
Welcome to reprint. Please indicate the source https://www.myzhenai.com.cn/post/2394.html

没有评论

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注