If you have access to OvenPlayer GitHub, you can download the latest version in development by pressing the Clone or Download button and clicking Download ZIP in the menu that appears.
For more advanced workflows, installing via npm is recommended.
Latest version
$ npm install ovenplayer
Version specified
$ npm install ovenplayer@0.10.0
Vuejs component
$ npm install ovenplayer-vue3
Quick Start
Below is a list of simple OvenPlayer initialization methods for each situation. For detailed options when initializing the OvenPlayer, please refer to the Initialization chapter.
Basic Concept
HTML
You need an HTML element where the OvenPlayer will be initialized.
<div id="player_id"></div>
Specifying the size or position of the player is possible by changing the style of the wrapper element.
<!-- Wrapper element for sizing or positioning the player -->
<div class="player-wrapper">
<!-- OvenPlayer will be initialized inside this element. -->
<div id="player_id"></div>
</div>
The width of the OvenPlayer is set equal to the width of the container. So with style below, the OvenPlayer will have a width of 1280px.
.player-wrapper {margin:0 auto;width:1280px;}
JavaScript
You can import ovenplayer.js and initialize OvenPlayer by calling OvenPlayer.create() as shown below:
Note: please call removePlayer first, ensure there's no active instance.
removePlayer(): remove player.
Initialize for OME
To play Sub-Second Latency Stream of OvenMediaEngine, set the source type to webrtc and set the file to the WebRTC Signaling URL with OvenMediaEngine. An explanation of the WebRTC Signaling URL can be found here.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OvenPlayer</title>
</head>
<body>
<!-- OvenPlayer will be initialized inside this element. -->
<div id="player_id"></div>
<!-- Load OvenPlayer via CDN -->
<script src="https://cdn.jsdelivr.net/npm/ovenplayer/dist/ovenplayer.js"></script>
<script>
// Initialize OvenPlayer
const player = OvenPlayer.create('player_id', {
sources: [
{
label: 'label_for_webrtc',
// Set the type to 'webrtc'
type: 'webrtc',
// Set the file to WebRTC Signaling URL with OvenMediaEngine
file: 'ws://ome_host:signaling_port/app/stream'
}
]
});
</script>
</body>
</html>
Initialize for Video File
This is a way to play video files in progressive download mode.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OvenPlayer</title>
</head>
<body>
<!-- OvenPlayer will be initialized inside this element. -->
<div id="player_id"></div>
<!-- Load OvenPlayer via CDN -->
<script src="https://cdn.jsdelivr.net/npm/ovenplayer/dist/ovenplayer.js"></script>
<script>
// Initialize OvenPlayer
const player = OvenPlayer.create('player_id', {
sources: [
{
label: 'label_for_video',
// Set the type to 'mp4', 'webm' or etc
type: 'mp4',
file: 'https://github.com/AirenSoft/OvenPlayer/raw/master/docs/assets/OCP_480.mp4'
}
]
});
</script>
</body>
</html>
Initialize for DASH
If you want to play MPEG-DASH, you need the dash.js.
You need to place the dash.js first, and then ovenplayer.js as shown below:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OvenPlayer</title>
</head>
<body>
<!-- OvenPlayer will be initialized inside this element. -->
<div id="player_id"></div>
<!-- You need dash.js to play MPEG-DASH. -->
<script src="https://cdn.jsdelivr.net/npm/dashjs@latest/dist/dash.all.debug.min.js"></script>
<!-- Load OvenPlayer via CDN -->
<script src="https://cdn.jsdelivr.net/npm/ovenplayer/dist/ovenplayer.js"></script>
<script>
// Initialize OvenPlayer
const player = OvenPlayer.create('player_id', {
sources: [
{
label: 'label_for_dash',
// Set the type to 'dash'
type: 'dash',
file: 'https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd'
}
]
});
</script>
</body>
</html>
You need to place the hls.js first, and then ovenplayer.js as shown below:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OvenPlayer</title>
</head>
<body>
<!-- OvenPlayer will be initialized inside this element -->
<div id="player_id"></div>
<!-- You need hls.js to play HLS. -->
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest/dist/hls.min.js"></script>
<!-- Load OvenPlayer via CDN -->
<script src="https://cdn.jsdelivr.net/npm/ovenplayer/dist/ovenplayer.js"></script>
<script>
// Initialize OvenPlayer
const player = OvenPlayer.create('player_id', {
sources: [
{
label: 'label_for_hls',
// Set the type to 'hls'
type: 'hls',
file: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8'
}
]
});
</script>
</body>
</html>
Initialize for Ads
If you want to use Ads in OvenPlayer, you need the Google IMA.
You need to set the IMA first, and then ovenplayer.js, as shown below:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OvenPlayer</title>
</head>
<body>
<!-- Wrapper element for resizing and positioning the player -->
<div class="player-wrapper">
<!-- OvenPlayer will be initialized inside this element. -->
<div id="player_id"></div>
</div>
<script type="text/javascript" src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>
<!-- Load OvenPlayer via CDN -->
<script src="https://cdn.jsdelivr.net/npm/ovenplayer/dist/ovenplayer.js"></script>
<script>
// Initialize OvenPlayer
const player = OvenPlayer.create('player_id', {
sources: [
{
label: 'label_for_video',
// Set the type to 'mp4', 'webm' or etc
type: 'mp4',
file: 'https://github.com/AirenSoft/OvenPlayer/raw/master/docs/assets/OCP_480.mp4'
}
],
// Set the AD tag URL
adTagUrl: "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator="
});
</script>
</body>
</html>