MSW Open Music Project
🔴 Demo: https://msw-open-music.live
The best way to search for a music is to load up a huge playlist and shuffle until you find it.
A 💪 light weight ⚡️ blazingly fast 🖥️ cross platform personal music streaming platform. Manage your existing music files and enjoy them on any devices.
Front-end web application build with react.js and water.css, back-end build with golang and sqlite.
Introduction
Screenshot
Features
-
🔎 Index your existing music files, and record file name and folder information.
-
📕 Use folder 📁 tag 🏷️ review 💬 to manage your music.
-
🌐 Provide a light weight web application with multi-language support.
-
👥 Multi-user support.
-
🔥 Call
ffmpegwith customizable preset to stream your music. -
🔗 Share music with others!
Try it if you...
-
Already saved a lot of music files on disk. 🖴
-
Downloaded tons of huge lossless music. 🎵
-
Wants to stream your music files from PC/Server to PC/phone. 😋
-
Wants to share your stored music. 😘
Usage
-
Modify the
secretinconfig.json -
Run back-end server
msw-open-music.exeormsw-open-music. Server will listen on 8080 port by default. Then open http://127.0.0.1:8080 to setup first admin account.
The front-end HTML files are under web/build
Setup first admin account
The first administrator account will be active automatically, other administrator accounts need active manually.
Go to register page, select the role to admin, and register the first admin account.
config.json
-
secretstring type. Secret to encrypt the session. -
database_namestring type. The filename ofsqlite3database. Will create if that file doesn't exist. -
addrstring type. The listen address and port. -
ffmpeg_config_listlist type, includeffmpegConfigobject. -
file_life_timeinteger type (second). Life time for temporary file. If the temporary file is not accessed for more than this time, back-end server will delete this file. -
cleaner_internalinteger type (second). Interval fortmpfschecking temporary file. -
rootstring type. Directory to store temporary files. Default is/tmp, please modify this directory if you are using Windows. Directory will be created if not exists. -
permission. Specify each API's permission level.0for no permission required.1require admin level (highest level) permission.2require normal user level permission. That is, both admins and registered users can access to this URL, except anonymous users.- If you want to avoid abuse of the playback API, you can adjust the permission level for these 5 playback-related APIs.
/get_fileget file withio.copy()method/get_file_directget file withhttp.serveFile()method/get_file_streamcall ffmpeg and stream itsstdoutoutput/prepare_file_stream_directcall ffmpeg to convert a file/get_file_stream_directget the converted file withhttp.serveFile()
- Other URLs not metion in
config.jsonwill have0permission level by default.
For windows user, make sure you have ffmpeg installed.
Development
Any issues or pull requests are welcome.
Major changes log
v1.0.0First version. Implement the core streaming function.v1.1.0UseReactto rewrite the font-end web pages.v1.2.0Add user, tag, review and other functions for DBMS course project.
ER Diagram
Database Entities Relationship Diagram
-
avataris not using currently -
The first time you run the program, the server will create an anonymous user with id
1. All users who are not logged in will be automatically logged in to this account. -
tmpfsis store in memory, which will be empty everytime server restart.
About tmpfs
If the Prepare mode is enabled in the font-wed player, back-end server will convert the whole file into the temporary folder, then serve file. This can avoid ffmpeg pipe break problem cause by unstable network connection while streaming audio.
The default temporary folder is /tmp, which is a tmpfs file system in Linux operating system. Default life time for temporary files is 600 seconds (10 minutes). If the temporary file is not accessed for more than this time, back-end server will delete this file.
Back-end API design
API does not need to respond any data will return the following JSON object.
{
"status": "OK"
}
Sometime errors happen, server will return the following JSON object, which error is the detailed error message.
{
"error": "Wrong password"
}
API does not need to send any data should use GET method, otherwise use POST method.
Server use cookies to authenticate a user. Any request without cookies will be consider from an anonymous user (aka. user with ID 1).
Some important source code files:
-
pkg/api/api.godefine URL -
pkg/database/sql_stmt.godefine SQL queries and do the init job. -
pkg/database/struct.godefine JSON structures for database entities.

