UI Customize
This section explains how to change the UI of OvenPlayer, such as modify styles, view templates, and more.
CSS Skinning
How to change accent the color
You can easily change the color by overriding the --op-accent-color class in your web page:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OvenPlayer</title>
<style>
/* Change the accent color */
#player_id {
--op-accent-color: red;
}
</style>
</head>
<body>
<div id="player_id"></div>
<script src="https://cdn.jsdelivr.net/npm/ovenplayer/dist/ovenplayer.js"></script>
<script>
// Initialize OvenPlayer
const player = OvenPlayer.create('player_id', {
sources: [
...
]
});
</script>
</body>
</html>How to change the style
assets/ contains the image file used as the button in OvenPlayer. And you can modify the style yourself in stylesheet/ovenplayer.less.
If you want to know how to build and run, go to the Builds tab.
Add and Edit a new UI
The view of OvenPlayer has consisted of a template that extended OvenTemplate.
The template has a minimal life cycle starting with onRendered() and ending with onDestroyed(), and you can set an event callback with a valid scope in the template.

The top-level parent template is view/view.js. View creates child Controls and Helpers templates. Also, Controls and Helpers create and control child templates, respectively.
Through our example TextView (view/example/textview.js), we will explain in the following part how child templates are created, controlled, and passed data by the parent template.
Register a template
The OvenPlayer template has a pair of controller and view, each named {templateName}.js and {templateName}Template.js.
You need to register view separately in Templates.
We have configured textviewTemplate.js corresponding to the view in the TextView. So you register textviewTemplate.js in view/engine/Templates.js.
Use a template
In this part, we will show you how to create the TextView in helpers/main.js, the top-level parent of Helpers.
You import textview.js which is controller in the TextView.
The source of the TextView is:
$container means the parent's element, and in onRendered(), onDestroyed(), and events(), $current means the element owned by each item.
LikeA$
$container and $current in OvenPlayerTemplate consist of LikeA$ object.
Create LikeA$ object
Search element
Access element
Edit CSS
Please check /utils/likeA$.js for more information. This is slightly more inconvenient than jquery but enough to control OvenPlayer.
Build and Run
You can build OvenPlayer through the Builds chapter.
You can see the added TextView by building OvenPlayer and running dist/development/ index.html.

In this way, you can add a new UI or customize the template.
Last updated
Was this helpful?