An HLS-based music streaming API with random playback capabilities / API phát nhạc trực tuyến với tính năng streaming HLS và phát ngẫu nhiên
- ✅ HLS (HTTP Live Streaming) support
- ✅ Auto-next track functionality
- ✅ Random playback
- ✅ Play count tracking
- ✅ Music file upload support
- ✅ Automatic processing and segmentation
- ✅ Multiple audio format support
- ✅ Multi-quality HLS playlist generation
| Table |
Purpose |
users |
User management & authentication |
albums |
Album metadata & cover art |
tracks |
Song metadata & file paths |
segments |
HLS segment information |
playlists |
HLS & user playlist data |
likes |
Track likes & favorites |
comments |
User comments & feedback |
- ⚡ Search optimization indexes
- 📊 SQLite WAL mode
- 🔄 Transaction support
- 📦 Streaming buffer & cache
- 🛡️ Comprehensive error handling
# Clone repository
git clone https://github.com/vovanhau123/HTTP-STREAMING.git
# Navigate to project
cd music-streaming-api
# Install dependencies
npm install
# Initialize directories
npm run init
# Start server
npm start
🌐 Server runs at http://localhost:3000
| Method |
Endpoint |
Description |
GET |
/api/tracks |
Get all tracks |
GET |
/api/tracks/:id/playlist |
Get track's HLS playlist |
GET |
/api/tracks/random |
Get random track |
GET |
/api/tracks/random/:genre |
Get random track by genre |
POST |
/api/tracks/:id/play |
Update play count |
| Method |
Endpoint |
Description |
GET |
/api/albums |
Get all albums |
GET |
/api/albums/:id |
Get album details with tracks |
POST |
/api/albums |
Create new album |
PUT |
/api/albums/:id |
Update album |
DELETE |
/api/albums/:id |
Delete album |
GET |
/api/albums/artist/:artist |
Get albums by artist |
GET |
/api/albums/genre/:genre |
Get albums by genre |
| Method |
Endpoint |
Description |
POST |
/upload |
Upload new music file |
| Method |
Endpoint |
Description |
POST |
/api/auth/register |
Register new user |
POST |
/api/auth/verify |
Verify email with code |
{
"email": "user@example.com",
"password": "StrongPass123",
"username": "username"
}
{
"code": "123456"
}
## 📂 Project Structure
music-streaming-api/
├── data/ # SQLite database
├── public/
│ ├── index.html # Frontend interface
│ └── streams/ # HLS stream files
├── src/
│ ├── config/ # App configuration
│ ├── controllers/ # Request handlers
│ ├── middleware/ # Custom middleware
│ ├── models/ # Data models
│ ├── routes/ # API routes
│ ├── services/ # Business logic
│ └── server.js # Entry point
├── uploads/ # Uploaded files
│ └── album-covers/ # Album cover images
└── package.json
## 🛠️ Tech Stack
<div align="center">






</div>
- **Backend**: Node.js, Express.js
- **Database**: SQLite3
- **Streaming**: HLS.js
- **File Upload**: Multer
## 🗺️ Roadmap
- [ ] 🔐 User authentication & authorization
- [ ] 📝 Playlist management system
- [ ] ❤️ Like & comment functionality
- [ ] 🔍 Advanced search with filters
- [ ] 🎯 Personalized recommendations
- [ ] 📊 Listening statistics & analytics
## 🤝 Contributing
1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## 📄 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## 📬 Contact
vovanhau123 - [@vovanhau123](https://twitter.com/4rge) - contact@4rge.dev
Project Link: [https://github.com/vovanhau123/HTTP-STREAMING](https://github.com/vovanhau123/HTTP-STREAMING)
---
<p align="center">
Made with ❤️ by vovanhau123
</p>