├── .eslintrc.cjs ├── .gitignore ├── README.md ├── example ├── .eslintrc.cjs ├── .gitignore ├── index.html ├── package-lock.json ├── package.json ├── public │ ├── Madza-Chords_of_Life.mp3 │ ├── Madza-Late_Night_Drive.mp3 │ ├── Madza-Persistence.mp3 │ └── vite.svg ├── src │ ├── App.jsx │ ├── components │ │ ├── Footer.jsx │ │ ├── Footer.module.css │ │ ├── Header.jsx │ │ ├── Header.module.css │ │ ├── Wrapper.jsx │ │ └── Wrapper.module.css │ ├── index.css │ └── main.jsx └── vite.config.js ├── index.html ├── package-lock.json ├── package.json ├── public └── vite.svg ├── src ├── App.jsx ├── components │ ├── ButtonsAndVolumeBox.jsx │ ├── ButtonsAndVolumeBox.module.css │ ├── ButtonsBox.jsx │ ├── ButtonsBox.module.css │ ├── Loop.jsx │ ├── Loop.module.css │ ├── Next.jsx │ ├── Next.module.css │ ├── PageTemplate.jsx │ ├── Pause.jsx │ ├── Pause.module.css │ ├── Play.jsx │ ├── Play.module.css │ ├── PlayerTemplate.jsx │ ├── PlayerTemplate.module.css │ ├── PlaylistItem.jsx │ ├── PlaylistItem.module.css │ ├── PlaylistTemplate.jsx │ ├── PlaylistTemplate.module.css │ ├── Previous.jsx │ ├── Previous.module.css │ ├── Progress.jsx │ ├── Progress.module.css │ ├── Search.jsx │ ├── Search.module.css │ ├── Shuffle.jsx │ ├── Shuffle.module.css │ ├── TagItem.jsx │ ├── TagItem.module.css │ ├── TagsTemplate.jsx │ ├── TagsTemplate.module.css │ ├── Time.jsx │ ├── Time.module.css │ ├── Title.jsx │ ├── Title.module.css │ ├── TitleAndTimeBox.jsx │ ├── TitleAndTimeBox.module.css │ ├── Volume.jsx │ └── Volume.module.css ├── icons │ ├── loop_current.png │ ├── loop_none.png │ ├── next.png │ ├── pause.png │ ├── play.png │ ├── previous.png │ ├── shuffle_all.png │ └── shuffle_none.png ├── index.css └── main.jsx └── vite.config.js /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:react/recommended', 7 | 'plugin:react/jsx-runtime', 8 | 'plugin:react-hooks/recommended', 9 | ], 10 | ignorePatterns: ['dist', '.eslintrc.cjs'], 11 | parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, 12 | settings: { react: { version: '18.2' } }, 13 | plugins: ['react-refresh'], 14 | rules: { 15 | 'react-refresh/only-export-components': [ 16 | 'warn', 17 | { allowConstantExport: true }, 18 | ], 19 | }, 20 | } 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React/NextJS Audio Player 2 | 3 | [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/madzadev/audio-player/graphs/commit-activity) 4 | [![GitHub issues](https://img.shields.io/github/issues/madzadev/audio-player)](https://github.com/madzadev/audio-player/issues/) 5 | [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) 6 | [![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://choosealicense.com/licenses/mit/) 7 | 8 | ![Player Preview](https://i.imgur.com/qVX68ve.gif) 9 | 10 | ### Demo: [https://audioplayer.madza.dev](https://audioplayer.madza.dev) 11 | 12 | --- 13 | 14 | ## Requirements 15 | 16 | Node.js 18.x / 20+ is required. 17 | 18 | Tested on React 18.2.0 and NextJS 14.1.0. 19 | 20 | ## Installation 21 | 22 | ```javascript 23 | npm install @madzadev/audio-player 24 | ``` 25 | 26 | ## Usage 27 | 28 | ```javascript 29 | import Player from "@madzadev/audio-player"; 30 | import "@madzadev/audio-player/dist/index.css"; 31 | ``` 32 | 33 | ```javascript 34 | const tracks = [ 35 | { 36 | url: "https://audioplayer.madza.dev/Madza-Chords_of_Life.mp3", 37 | title: "Madza - Chords of Life", 38 | tags: ["house"], 39 | }, 40 | { 41 | url: "https://audioplayer.madza.dev/Madza-Late_Night_Drive.mp3", 42 | title: "Madza - Late Night Drive", 43 | tags: ["dnb"], 44 | }, 45 | { 46 | url: "https://audioplayer.madza.dev/Madza-Persistence.mp3", 47 | title: "Madza - Persistence", 48 | tags: ["dubstep"], 49 | }, 50 | ]; 51 | ``` 52 | 53 | ```javascript 54 | 55 | ``` 56 | 57 | The only mandatory prop is `trackList` for audio source. 58 | 59 | It requires to pass in an array consisting of objects with `url`, `title` and `tags` keys. 60 | 61 | ## Options 62 | 63 | There are multiple optional props you can use to configure the player. 64 | 65 | The default values of them are displayed below. 66 | 67 | ```javascript 68 | 76 | ``` 77 | 78 | ## Color schemes 79 | 80 | You can customize the design of the player by editing the `colors` object below. 81 | 82 | Include only those properties, that you want to customize. 83 | 84 | ```javascript 85 | const colors = { 86 | tagsBackground: "#3e32e4", 87 | tagsText: "#ffffff", 88 | tagsBackgroundHoverActive: "#6e65f1", 89 | tagsTextHoverActive: "#ffffff", 90 | searchBackground: "#18191f", 91 | searchText: "#ffffff", 92 | searchPlaceHolder: "#575a77", 93 | playerBackground: "#18191f", 94 | titleColor: "#ffffff", 95 | timeColor: "#ffffff", 96 | progressSlider: "#3e32e4", 97 | progressUsed: "#ffffff", 98 | progressLeft: "#151616", 99 | bufferLoaded: "#1f212b", 100 | volumeSlider: "#3e32e4", 101 | volumeUsed: "#ffffff", 102 | volumeLeft: "#151616", 103 | playlistBackground: "#18191f", 104 | playlistText: "#575a77", 105 | playlistBackgroundHoverActive: "#18191f", 106 | playlistTextHoverActive: "#ffffff", 107 | }; 108 | ``` 109 | 110 | ```javascript 111 | 112 | ``` 113 | 114 | ## Final notes 115 | 116 | The audio files can be stored and accessed both locally in your project via file path (e.g., `public/yourtrack.mp3`) or using external host and providing direct URL to the source (e.g., `https://website.com/yourtrack.mp3`). 117 | 118 | This project is under MIT license, so be free to check it out and contribute! 119 | -------------------------------------------------------------------------------- /example/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { browser: true, es2020: true }, 4 | extends: [ 5 | 'eslint:recommended', 6 | 'plugin:react/recommended', 7 | 'plugin:react/jsx-runtime', 8 | 'plugin:react-hooks/recommended', 9 | ], 10 | ignorePatterns: ['dist', '.eslintrc.cjs'], 11 | parserOptions: { ecmaVersion: 'latest', sourceType: 'module' }, 12 | settings: { react: { version: '18.2' } }, 13 | plugins: ['react-refresh'], 14 | rules: { 15 | 'react-refresh/only-export-components': [ 16 | 'warn', 17 | { allowConstantExport: true }, 18 | ], 19 | }, 20 | } 21 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | dist 12 | dist-ssr 13 | *.local 14 | 15 | # Editor directories and files 16 | .vscode/* 17 | !.vscode/extensions.json 18 | .idea 19 | .DS_Store 20 | *.suo 21 | *.ntvs* 22 | *.njsproj 23 | *.sln 24 | *.sw? 25 | -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Audio Player Example 8 | 9 | 10 |
11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@madzadev/audio-player-example", 3 | "version": "2.1.14", 4 | "type": "module", 5 | "scripts": { 6 | "dev": "vite", 7 | "build": "vite build", 8 | "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "@madzadev/audio-player": "^2.1.14", 13 | "react": "^18.2.0", 14 | "react-dom": "^18.2.0", 15 | "react-syntax-highlighter": "npm:@fengkx/react-syntax-highlighter@15.6.1" 16 | }, 17 | "devDependencies": { 18 | "@types/react": "^18.2.55", 19 | "@types/react-dom": "^18.2.17", 20 | "@vitejs/plugin-react": "^4.2.1", 21 | "eslint": "^8.55.0", 22 | "eslint-plugin-react": "^7.33.2", 23 | "eslint-plugin-react-hooks": "^4.6.0", 24 | "eslint-plugin-react-refresh": "^0.4.5", 25 | "vite": "^5.0.8" 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /example/public/Madza-Chords_of_Life.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madzadev/audio-player/c0922db7bd9ff14c05dedd7ede9fec3b01002382/example/public/Madza-Chords_of_Life.mp3 -------------------------------------------------------------------------------- /example/public/Madza-Late_Night_Drive.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madzadev/audio-player/c0922db7bd9ff14c05dedd7ede9fec3b01002382/example/public/Madza-Late_Night_Drive.mp3 -------------------------------------------------------------------------------- /example/public/Madza-Persistence.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madzadev/audio-player/c0922db7bd9ff14c05dedd7ede9fec3b01002382/example/public/Madza-Persistence.mp3 -------------------------------------------------------------------------------- /example/public/vite.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/src/App.jsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import Wrapper from "./components/Wrapper"; 3 | import Header from "./components/Header"; 4 | import Footer from "./components/Footer"; 5 | 6 | import Player from "@madzadev/audio-player"; 7 | import "@madzadev/audio-player/dist/index.css"; 8 | 9 | import { PrismLight as SyntaxHighlighter } from "react-syntax-highlighter"; 10 | import { coldarkDark } from "react-syntax-highlighter/dist/esm/styles/prism"; 11 | 12 | import bash from "react-syntax-highlighter/dist/esm/languages/prism/bash"; 13 | import jsx from "react-syntax-highlighter/dist/esm/languages/prism/jsx"; 14 | import javascript from "react-syntax-highlighter/dist/esm/languages/prism/javascript"; 15 | SyntaxHighlighter.registerLanguage("bash", bash); 16 | SyntaxHighlighter.registerLanguage("jsx", jsx); 17 | SyntaxHighlighter.registerLanguage("javascript", javascript); 18 | 19 | const tracks = [ 20 | { 21 | url: "https://audioplayer.madza.dev/Madza-Chords_of_Life.mp3", 22 | title: "Madza - Chords of Life", 23 | tags: ["house"], 24 | }, 25 | { 26 | url: "https://audioplayer.madza.dev/Madza-Late_Night_Drive.mp3", 27 | title: "Madza - Late Night Drive", 28 | tags: ["dnb"], 29 | }, 30 | { 31 | url: "https://audioplayer.madza.dev/Madza-Persistence.mp3", 32 | title: "Madza - Persistence", 33 | tags: ["dubstep"], 34 | }, 35 | ]; 36 | 37 | const App = () => { 38 | return ( 39 | 40 |
41 | 42 |

Installation

43 | 44 | {`npm install @madzadev/audio-player`} 45 | 46 | 47 |

Usage

48 | 49 | {`import Player from '@madzadev/audio-player' 50 | import '@madzadev/audio-player/dist/index.css'`} 51 | 52 | 53 | {`const tracks = [ 54 | { 55 | url: 'https://audioplayer.madza.dev/Madza-Chords_of_Life.mp3', 56 | title: 'Madza - Chords of Life', 57 | tags: ['house'] 58 | }, 59 | { 60 | url: 'https://audioplayer.madza.dev/Madza-Late_Night_Drive.mp3', 61 | title: 'Madza - Late Night Drive', 62 | tags: ['dnb'] 63 | }, 64 | { 65 | url: 'https://audioplayer.madza.dev/Madza-Persistence.mp3', 66 | title: 'Madza - Persistence', 67 | tags: ['dubstep'] 68 | } 69 | ]`} 70 | 71 | 72 | {``} 73 | 74 |

75 | The only mandatory prop is trackList for audio source. 76 |

77 |

78 | It requires to pass in an array consisting of objects with{" "} 79 | url, title and tags keys. 80 |

81 | 82 |

Options

83 |

84 | There are multiple optional props you can use to configure the player. 85 |

86 |

The default values of them are displayed below.

87 | 88 | {``} 96 | 97 | 98 |

Color schemas

99 |

100 | You can customize the design of the player by editing the{" "} 101 | colors object below. 102 |

103 |

104 | Include only those properties, that you want to customize. 105 |

106 | 107 | {`const colors = { 108 | tagsBackground: "#3e32e4", 109 | tagsText: "#ffffff", 110 | tagsBackgroundHoverActive: "#6e65f1", 111 | tagsTextHoverActive: "#ffffff", 112 | searchBackground: "#18191f", 113 | searchText: "#ffffff", 114 | searchPlaceHolder: "#575a77", 115 | playerBackground: "#18191f", 116 | titleColor: "#ffffff", 117 | timeColor: "#ffffff", 118 | progressSlider: "#3e32e4", 119 | progressUsed: "#ffffff", 120 | progressLeft: "#151616", 121 | bufferLoaded: "#1f212b", 122 | volumeSlider: "#3e32e4", 123 | volumeUsed: "#ffffff", 124 | volumeLeft: "#151616", 125 | playlistBackground: "#18191f", 126 | playlistText: "#575a77", 127 | playlistBackgroundHoverActive: "#18191f", 128 | playlistTextHoverActive: "#ffffff", 129 | }`} 130 | 131 | 132 | {``} 136 | 137 | 138 |

Final notes

139 |

140 | The audio files can be stored and accessed both locally in your project 141 | via file path (e.g., public/yourtrack.mp3) or using 142 | external host and providing direct URL to the source (e.g.,{" "} 143 | https://website.com/yourtrack.mp3). 144 |

145 |

146 | This project is under MIT license, so be free to check it out! 147 |

148 | 149 |