Total Pageviews

Thursday, 11 March 2021

基于nodejs的流媒体音乐服务器程序koel

  A personal music streaming server that works. https://koel.dev/

Intro

Koel (also stylized as koel, with a lowercase k) is a simple web-based personal audio streaming service written in Vue on the client side and Laravel on the server side. Targeting web developers, Koel embraces some of the more modern web technologies – CSS grid, audio, and drag-and-drop API to name a few – to do its job.

Install and Upgrade Guide

For system requirements, installation/upgrade guides, troubleshooting etc., head over to the Official Documentation.

Development

Since Koel makes use of git submodules, you'll want to make sure the submodule is up-to-date:

git pull
git submodule update --init --recursive --remote

# install the submodule dependencies
cd resources/assets
yarn install

To start the PHP dev server, which serves as the API of the application, run the following command from the root directory. By default, the server will listen at port 8000.

php artisan serve

For the client application itself, run this command:

yarn hot

A development version of Koel should now be available at http://localhost:8080 with full support for hot module reloading.

Alternatively, you can start both the PHP server and the client application in one go with yarn dev, which uses start-server-and-test under the hood.

Testing, Linting, Static Analysis and Stuff

# PHP-related code quality tasks
# Basically, take a look at the "scripts" section in composer.json
composer test        # Run the PHP test suite
composer cs          # Run code style checker
composer cs:fix      # Run code style fixer 
composer analyze     # Run PHP static analysis

yarn build # Build a production version of the client application

# Client/E2E code quality tasks
# You may want to run `yarn build` first.
yarn test:e2e        # Run the Cypress test suite interactively
yarn test:e2e:ci     # Run the Cypress test suite non-interactively (CI mode)
# These commands need to be run from within the submodule (resources/assets)
yarn lint            # Lint
yarn type-check      # TypeScript type checking
yarn test            # Unit testing

Note: If you're already running yarn test:e2e, there's no need to start a dev server. yarn test:e2e calls yarn dev internally and will eliminate the existing yarn dev process, if any.

A quick and easy way to start hacking on koel is to open and run this repo in Gitpod, an online IDE with full Laravel support.

Open in Gitpod

from https://github.com/koel/koel 

----

koel, 私人音乐串流伺服器

koel是一个用Laravel+Vue.js做的开源音乐串流伺服器架设好之后是蛮方便的,在手机ipad之类的装置上只要打开浏览器就能直接播放电脑上的音乐

这篇文章是一篇简单的在Windows 上建立koel 伺服器的教学

官方教学: Koel docs不过官方的教学稍微简略了一些,对Windows使用者来说可能不是简单的能依照上面搞定,因此才有这篇文章的出现.

前置准备

所有的指令请在有管理员权限的powershell 下执行

Chocolatey

为了能轻松的安装必要的软体,需要先安装Chocolatey

官方的安装教学

执行下面这行指令

1
Set-ExecutionPolicy Bypass -Scope  Process  -Force ; iex (( New-Object System.Net.WebClient).DownloadString( 'https://chocolatey.org/install.ps1' ))

然后执行choco -v指令,如果没有出现错误并显示版本号就代表安装成功了

php & composer

执行:

1
choco install php composer -y

然后可能要稍微等一段时间下载与安装完成后可以用php -vcomposer -V来看有没有安装成功

接下来koel 需要启用一些php 的extension 才能正常使用

执行:

1 
2
3
4
5
6
php - -ini 
#输出:
# Configuration File (php.ini) Path: C:\WINDOWS
# Loaded Configuration File: C:\tools\php72\php.ini
# Scan for additional .ini files in: (none)
# Additional .ini files parsed: (none)

然后用文字编辑器打开Loaded Configuration File:后面显示的档案

在档案中找到;extension=exif;extension=pdo_sqlite,;extension=fileinfo分别改成extension=exifextension=pdo_sqlite,extension=fileinfo然后储存档案

node.js & yarn & git

执行:

1
choco install nodejs yarn git -y

一样能透过node -vyarn -v检查是否安装成功这个就没有什么东西需要额外设定的了

安装

下载

这边假设想把koel安装到D:\koel的位置执行:

1 
2
3
4
5
6
cd D: #切换到D槽
git clone https://github.com/phanan/koel.git koel #后面的koel是资料夹名称
cd koel #进入资料夹
git checkout v3. 7.2 #在https://github .com/phanan/koel/releases检查最新版的版本号
composer install #安装一些必要的package
New-Item database/e2e.sqlite -type file #建立资料库档案database/e2e.sqlite,之后会用到

要把上面的指令执行完成可能也要不少时间,尤其是composer install最慢(大概5分钟)

设定

再来是要执行php artisan koel:init,这个指令会互动式的问好几个问题例如音乐的资料夹位置,管理员的名称、信箱、密码

不过其中有一项是Database(资料库),这一项请输入sqlite然后后面问你的sqlite位置请填D:\koel\database\e2e.sqlite(绝对路径,前面要根据你的资料夹位置更改)

如果前面询问音乐资料夹时已经有填入位置的话,建议先执行php artisan koel:sync来初次更新资料库

到这边安装已经完成了,输入php artisan serve然后打开http://localhost:8000应该就能看到登入介面

输入前面所设定的email 和密码之后就能进到介面并在浏览器中享受音乐

如需在网页介面设定音乐资料夹位置的话进入左侧Settings然后在Media Path栏位填音乐资料夹的绝对路径

更改port

如果不想要使用port 8000的话可以把指令改成php artisan serve --port=1234这样就会让port开在1234

允许同wifi 使用koel

执行指令ipconfig应该能看到自己在wifi下的ip,例如我是192.168.0.20如果在手机或其他在同个wifi下的装置用浏览器浏览192.168.0.20:8000时已经可以的话建议可以跳过这一段

在koel的资料夹下用文字编辑器打开.env,并找到一行APP_URL=xxxxxx改成http://192.168.0.20这样的网址请自己替换成正确的ip

然后未来的启动伺服器指令要改成php artisan serve --host=192.168.0.20才能使用192.168.0.20来连接

背景自动启动

背景启动

自动启动如果直接使用batch 来做会导致视窗不会关掉的问题,所以会使用到vbscript

在koel的资料夹底下建立一个档案叫init.vbs内容打上:

1
CreateObject ( "WScript.Shell" ).Run "php artisan serve --host=192.168.0.20" , 0 , True

中间的字串要改成自己要的启动指令

这样只要在init.vbs上点两下就会自动启动伺服器并让视窗消失

开机自动执行

按下win+R,在执行的视窗中输入shell:startup并按确定就会打开一个资料夹这个资料夹里的档案在开机时都会被自动执行,所以要在这边建立initkoel.bat内容则打上:

1 
2
cd /d D:\koel 
start /b init.vbs

要把cd的路径改成你的koel资料夹如果不是放在C:,就不能把\d拿掉

Youtube & Last.fm

官方的教学: https://koel.phanan.net/docs/#/3rd-party



No comments:

Post a Comment