There are several ways to install the Ravnur Media Player. You can use it via CDN, add it to your codebase, or fetch it using the npm registry.
Include the Ravnur Media Player script in your HTML file by adding the following CDN link in the <head> section:
<script src="https://unpkg.com/ravnur-player-public@latest/dist/cdn/RavnurMediaPlayer.min.js"></script>
Alternatively, you can download and include the Ravnur Media Player script to your project's codebase:
<script src="path/to/RavnurMediaPlayer.min.js"></script>
You can also install Ravnur Media Player using the NPM package manager.
1. Install Ravnur Player
npm install ravnur-player-public
2. Include the player import in the file
import { RavnurMediaPlayer } from 'ravnur-player-public'
To use the Ravnur Media Player, initiate a new instance by providing the target element and styles:
<div id="player" style="max-width: 720px; height: 400px;"></div>
// Retrieve the HTML element where the player will be initialized
const element = document.getElementById('player');
// Define custom styling options for the player (Optional)
const styles = { ... }; // PlayerStyles type
// Initialize the Ravnur Media Player instance
const player = new RavnurMediaPlayer(element, styles);
styles parameter accepts a PlayerStyles object for customizing the player's appearance. By following these instructions, you'll successfully initialize the Ravnur Media Player for integration into your web application.
After initialization, set up the player with a media source and additional options.
// Define an object containing media source information
let media = {
src: 'YOUR_MEDIA_SOURCE_URL',
type: "YOUR_MEDIA_MIME_TYPE",
}; // PlayerSource type
// Object containing player options
let options = { ... };
player.setup(media, options);
You can use the destroy method to remove a player from the DOM and destroy it.
player.destroy();
player = null;