Skip to content

Commit

Permalink
Add setSource method
Browse files Browse the repository at this point in the history
  • Loading branch information
rtritto committed Feb 18, 2025
1 parent 2d8cc06 commit 0009f56
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ The player instance exposes the following methods, accessible when the player is
| `mute()` | - | - | Mute the volume |
| `unMute()` | - | - | Unmute the volume |
| `seekTo(time)` | `Number` | - | Seek to a current time in seconds |
| `setSource(source)` | `String` | - | Set the media source |
| `requestFullscreen()` | - | - | Request the fullscreen |
| `exitFullscreen()` | - | - | Exit the fullscreen |
| `getInstance()` | - | - | Get the player instance |
Expand Down
9 changes: 9 additions & 0 deletions src/core/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,15 @@ export default class Player {
this.methodSeekTo(newTime)
}

/**
* Set the media source
* @param source New media source URL
*/
setSource(source: string) {
this.media.src = source;
this.media.load();
}

/**
* Request the fullscreen
*/
Expand Down

0 comments on commit 0009f56

Please sign in to comment.