Β
Β
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Β | Β | |||
Β | Β | |||
Β | Β | |||
Repository files navigation
# π΅ Music Streaming API > 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 <p align="center"> <img src="docs/images/preview.png" alt="Preview" width="600"/> </p> ## β¨ Features ### π§ Music Playback - β HLS (HTTP Live Streaming) support - β Auto-next track functionality - β Random playback - β Play count tracking ### π File Management - β Music file upload support - β Automatic processing and segmentation - β Multiple audio format support - β Multi-quality HLS playlist generation ### πΎ Database Structure | Table | Purpose | |-------|---------| | `users` | User management & authentication | | `tracks` | Song metadata & file paths | | `segments` | HLS segment information | | `playlists` | HLS & user playlist data | | `likes` | Track likes & favorites | | `comments` | User comments & feedback | ### π Optimizations - β‘ Search optimization indexes - π SQLite WAL mode - π Transaction support - π¦ Streaming buffer & cache - π‘οΈ Comprehensive error handling ## π οΈ Installation ```bash # 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` ## π‘ API Endpoints ### π΅ Tracks | 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 | ### π€ Upload | Method | Endpoint | Description | |--------|----------|-------------| | `POST` | `/upload` | Upload new music file | ## π 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 βββ package.json ``` ## π οΈ Tech Stack <p align="center"> <img src="https://nodejs.org/static/images/logo.svg" alt="Node.js" width="60" height="60"/> <img src="https://expressjs.com/images/express-facebook-share.png" alt="Express.js" width="60" height="60"/> <img src="https://www.sqlite.org/images/sqlite370_banner.gif" alt="SQLite" width="60" height="60"/> <img src="https://raw.githubusercontent.com/video-dev/hls.js/master/doc/design/logo.png" alt="HLS.js" width="60" height="60"/> </p> - **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 Your Name - [@yourtwitter](https://twitter.com/yourtwitter) - email@example.com Project Link: [https://github.com/vovanhau123/HTTP-STREAMING](https://github.com/vovanhau123/HTTP-STREAMING) --- <p align="center"> Made with β€οΈ by vovanhau123 </p>