Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davland7/rplayer
Play streaming radio HTML5 .mp3 & .m3u8
https://github.com/davland7/rplayer
hls javascript mp3
Last synced: 7 days ago
JSON representation
Play streaming radio HTML5 .mp3 & .m3u8
- Host: GitHub
- URL: https://github.com/davland7/rplayer
- Owner: davland7
- License: mit
- Created: 2016-05-06T22:04:01.000Z (about 8 years ago)
- Default Branch: main
- Last Pushed: 2024-04-04T18:47:13.000Z (3 months ago)
- Last Synced: 2024-06-06T02:26:35.181Z (about 1 month ago)
- Topics: hls, javascript, mp3
- Language: HTML
- Homepage: https://rplayer.js.org
- Size: 968 KB
- Stars: 36
- Watchers: 4
- Forks: 12
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- docsify-awesome-stars - davland7/rplayer - Play streaming radio HTML5 .mp3 & .m3u8 (HTML)
- awesome-jekyll - davland7/rplayer - Play streaming radio HTML5 .mp3 & .m3u8 (HTML)
- awesome-stars - davland7/rplayer - Play streaming radio HTML5 .mp3 & .m3u8 (HTML)
README
# rPlayer in Action
rPlayer is a player play streaming radio, this player, offers the possibility to change different audio format. Example: .m3u8, .mp3, .aac.
## Easy to use
### NPM
```
npm install @davland7/rplayerimport audio from '@davland7/rplayer';
```### CDN
```
```
```
const audio = new rPlayer();
```rPlayer is extending [Audio](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio) HTMLMediaElement
## Play
Play doesn't work with HLS. 🙁
```
const audio = new Audio('URL.m3u8');
audio.play();
```Or
```
audio.src = 'URL.m3u8';
audio.play();
```Works with HLS. It's Magic 💪
```
audio.playSrc('URL.m3u8');
```> [!IMPORTANT]
> **rPlayer** is optimized for HLS content. While HLS is native to Apple devices, for Windows and Android, it's crucial to use the hls.js library for proper .m3u8 stream functionality. Please ensure the use of hls.js on devices other than iPhone and iPad.In addition to .m3u8, you can also use .mp3, .aac, .ogg and others. 😮
```
audio.playSrc('URL.aac');
```
> [!TIP]
> You can use rPlayer without hls.js if you don't need to support HLS formats like .m3u8. juste not add hls.js to your project.## Set Volume
The volume must not be outside the range [0, 1].
```
audio.volume = 0.2; // 0.2 Default set in local storage
```localStorage is very cool. 😎
## Extras
### Stop
```
audio.stop();
```### Mute
```
audio.mute();
```### Rewind
```
audio.rewind(10); // seconds
```### Volume Up
```
audio.upVolume();
```A way not to make a mistake if the range is not good. 😉
### Volume Down
10 levels up and down and blocks both ends. 😁
```
audio.downVolume();
```> [!WARNING]
> On iOS devices such as iPad and iPhone, the audio level is always controlled by the user physically. This means that the volume property is not adjustable through JavaScript on iOS devices. When you read the volume property on iOS, it will always return 1, reflecting that the user has direct control over the device's volume. Additionally, the library will always return 1 on iOS.## timeupdate event
The [timeupdate event](http://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/timeupdate_event) is fired when the time indicated by the currentTime attribute has been updated.
```
audio.ontimeupdate = function() {
console.log('Time:', audio.currentTime);
};
```## Infos
```
console.log('Source:', audio.url);
console.log('Playing:', audio.playing);
console.log('Paused:', audio.paused);
console.log('Muted:', audio.muted);
console.log('Volume:', audio.volume * 100);
console.log('hls.js:', audio.isHls);
console.log('Time:', audio.currentTime);
```rPlayer 2.2.4
[![](https://data.jsdelivr.com/v1/package/npm/@davland7/rplayer/badge)](https://www.jsdelivr.com/package/npm/@davland7/rplayer)
## Used by
[Mini Radio (Chrome extension)](https://chrome.google.com/webstore/detail/mini-radio/klcjochgjlcecbalpokmcldlfhngcnfh)