Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change style options and a new setting for intializing #50

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,19 @@ To add breaks in the video, simply add a new time (in seconds) in the list of br
});

### Customize marker style:
The style of the markers could be modified by passing an optional setting "markerStyle" with your preference of css styles.
The style of the markers could be modified by passing an optional setting "markerTip.style" with your preference of css styles.
You can also customise each marker style on it's own.

video.markers({
markerStyle: {
'width':'8px',
'background-color': 'red'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm inclined to not make this change since it is a big breaking change to the API. Moving markerStyle to markerTip.style isn't appropriate either because markerTip is used for the hover-over pointer thing.

markerTip: {
style: {
'width':'8px',
'background-color': 'red'
}
},
markers: [
{time: 9.5, text: "this"},
{time: 16, text: "is"},
{time: 16, text: "is", style: {'background-color': 'yellow'}},
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just took another look. Currently, we offer the ability to append class to marker object like {time: 9.5, text: "this", overlayText: "1", class: "special-blue"}, which achieves the same thing as passing a style object.

Is there a scenario where you can't pass in a class name and need hardcoded style?

{time: 23.6,text: "so"},
{time: 28, text: "cool"}
]
Expand Down
33 changes: 14 additions & 19 deletions dist/videojs-markers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dist/videojs.markers.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
bottom: 0em;
opacity: 1;
height: 100%;
width: 7px;
border-radius: 30%;
-moz-border-radius: 30%;
-webkit-border-radius: 30%;
background-color: red;
transition: opacity .2s ease;
-webkit-transition: opacity .2s ease;
-moz-transition: opacity .2s ease;
Expand Down Expand Up @@ -52,6 +57,11 @@
position: absolute;
z-index: 100000;
top: 0;
width: 100%;
height: 20%;
background-color: rgba(0,0,0,0.7);
color: white;
font-size: 17px;
}
.vjs-break-overlay .vjs-break-overlay-text {
padding: 9px;
Expand Down
31 changes: 13 additions & 18 deletions src/videojs.markers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ type Marker = {
(function($, videojs, undefined) {
// default setting
const defaultSetting = {
markerStyle: {
'width':'7px',
'border-radius': '30%',
'background-color': 'red',
},
markerTip: {
display: true,
text: function(marker) {
Expand All @@ -30,23 +25,19 @@ type Marker = {
time: function(marker) {
return marker.time;
},
style: {}
},
breakOverlay:{
display: false,
displayTime: 3,
text: function(marker) {
return "Break overlay: " + marker.overlayText;
},
style: {
'width':'100%',
'height': '20%',
'background-color': 'rgba(0,0,0,0.7)',
'color': 'white',
'font-size': '17px',
},
style: {},
},
onMarkerClick: function(marker) {},
onMarkerReached: function(marker, index) {},
directInitialize: false,
markers: [],
};

Expand Down Expand Up @@ -107,7 +98,7 @@ type Marker = {
function createMarkerDiv(marker: Marker): Object {
var markerDiv = $("<div class='vjs-marker'></div>");
markerDiv
.css(setting.markerStyle)
.css(marker.style ? $.extend({}, setting.markerTip.style, marker.style) : setting.markerTip.style)
.css({
"margin-left" : -parseFloat(markerDiv.css("width"))/2 + 'px',
"left" : getPosition(marker) + '%',
Expand Down Expand Up @@ -338,11 +329,6 @@ type Marker = {
player.on("timeupdate", onTimeUpdate);
}

// setup the plugin after we loaded video's meta data
player.on("loadedmetadata", function() {
initialize();
});

// exposed plugin API
player.markers = {
getMarkers: function(): Array<Marker> {
Expand Down Expand Up @@ -404,6 +390,15 @@ type Marker = {
delete player.markers;
},
};

if (setting.directInitialize) {
initialize();
} else {
// setup the plugin after we loaded video's meta data
player.on("loadedmetadata", function() {
initialize();
});
}
}

videojs.plugin('markers', registerVideoJsMarkersPlugin);
Expand Down
10 changes: 10 additions & 0 deletions src/videojs.markers.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
bottom: 0em;
opacity: 1;
height:100%;
width: 7px;
border-radius: 30%;
-moz-border-radius: 30%;
-webkit-border-radius: 30%;
background-color: red;
transition: opacity .2s ease;
-webkit-transition: opacity .2s ease;
-moz-transition: opacity .2s ease;
Expand Down Expand Up @@ -54,6 +59,11 @@
position: absolute;
z-index: 100000;
top: 0;
width: 100%;
height: 20%;
background-color: rgba(0,0,0,0.7);
color: white;
font-size: 17px;
.vjs-break-overlay-text{
padding: 9px;
text-align: center;
Expand Down