Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roman Karwacik
website
Commits
fa67b084
Commit
fa67b084
authored
8 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
fixed resolution switcher displaying the wrong label, closes #267
parent
223b6f29
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
static/videojs/videojs-resolution-switcher.js
+43
-4
43 additions, 4 deletions
static/videojs/videojs-resolution-switcher.js
templates/macros.html
+1
-1
1 addition, 1 deletion
templates/macros.html
with
44 additions
and
5 deletions
static/videojs/videojs-resolution-switcher.js
+
43
−
4
View file @
fa67b084
/*! videojs-resolution-switcher - 201
5-7-26
/*! videojs-resolution-switcher - 201
7-05-20
* Copyright (c) 2016 Kasper Moskwiak
* Copyright (c) 2016 Kasper Moskwiak
* Modified by Pierre Kraft
and
Derk-Jan Hartman
* Modified by Pierre Kraft
,
Derk-Jan Hartman
and Andreas Valder
* Licensed under the Apache-2.0 license. */
* Licensed under the Apache-2.0 license. */
(
function
()
{
(
function
()
{
...
@@ -70,9 +70,40 @@
...
@@ -70,9 +70,40 @@
}
);
}
);
ResolutionMenuButton
.
prototype
.
createItems
=
function
(){
ResolutionMenuButton
.
prototype
.
createItems
=
function
(){
var
menuItems
=
[];
var
menuItems
=
[];
var
labels
=
(
this
.
sources
&&
this
.
sources
.
label
)
||
{};
// FIXME order is not guaranteed here.
// one large hack to sort the labels
var
labels
=
(
this
.
sources
&&
this
.
sources
.
label
)
||
[];
var
sortable
=
[];
for
(
var
l
in
labels
)
{
sortable
.
push
({
'
key
'
:
l
,
'
value
'
:
labels
[
l
]});
}
sortable
.
sort
(
function
(
a
,
b
)
{
var
calcPixel
=
function
(
item
)
{
var
exp
=
item
.
res
.
replace
(
'
x
'
,
'
*
'
);
if
(
exp
!=
item
.
res
)
{
return
eval
(
exp
);
}
else
{
return
0
;
}
};
if
(
a
.
value
[
0
].
res
&&
b
.
value
[
0
].
res
)
{
return
calcPixel
(
a
.
value
[
0
])
-
calcPixel
(
b
.
value
[
0
]);
}
return
0
;
});
sortable
.
reverse
();
var
labels
=
{}
for
(
var
i
=
0
;
i
<
sortable
.
length
;
i
++
)
{
if
(
!
labels
[
sortable
[
i
].
key
])
{
labels
[
sortable
[
i
].
key
]
=
[];
}
for
(
var
l
=
0
;
l
<
sortable
[
i
].
value
.
length
;
l
++
)
{
labels
[
sortable
[
i
].
key
].
push
(
sortable
[
i
].
value
[
l
]);
}
}
labels
=
labels
||
{};
//hack ends here
for
(
var
key
in
labels
)
{
for
(
var
key
in
labels
)
{
if
(
labels
.
hasOwnProperty
(
key
))
{
if
(
labels
.
hasOwnProperty
(
key
))
{
menuItems
.
push
(
new
ResolutionMenuItem
(
menuItems
.
push
(
new
ResolutionMenuItem
(
...
@@ -117,6 +148,11 @@
...
@@ -117,6 +148,11 @@
player
.
updateSrc
=
function
(
src
){
player
.
updateSrc
=
function
(
src
){
//Return current src if src is not given
//Return current src if src is not given
if
(
!
src
){
return
player
.
src
();
}
if
(
!
src
){
return
player
.
src
();
}
for
(
var
i
=
0
;
i
<
src
.
length
;
i
++
)
{
src
[
i
].
res
=
src
[
i
][
'
data-res
'
];
src
[
i
].
label
=
src
[
i
][
'
data-label
'
];
src
[
i
].
prio
=
-
src
[
i
][
'
data-player_prio
'
];
}
// Only add those sources which we can (maybe) play
// Only add those sources which we can (maybe) play
src
=
src
.
filter
(
function
(
source
)
{
src
=
src
.
filter
(
function
(
source
)
{
...
@@ -217,6 +253,9 @@
...
@@ -217,6 +253,9 @@
* @returns {Number} result of comparation
* @returns {Number} result of comparation
*/
*/
function
compareResolutions
(
a
,
b
){
function
compareResolutions
(
a
,
b
){
if
(
a
.
prio
&&
b
.
prio
){
return
(
+
b
.
prio
)
-
(
+
a
.
prio
)
}
if
(
!
a
.
res
||
!
b
.
res
){
return
0
;
}
if
(
!
a
.
res
||
!
b
.
res
){
return
0
;
}
return
(
+
b
.
res
)
-
(
+
a
.
res
);
return
(
+
b
.
res
)
-
(
+
a
.
res
);
}
}
...
...
This diff is collapsed.
Click to expand it.
templates/macros.html
+
1
−
1
View file @
fa67b084
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
{% macro player(lecture, videos, msgs) %}
{% macro player(lecture, videos, msgs) %}
<video
id=
"videoplayer"
style=
"width: 100%"
class=
"video-js vjs-default-skin vjs-big-play-centered"
width=
"640"
height=
"320"
controls
data-wasnotplayed=
"1"
data-setup=
'{ "language":"de", "plugins" : {"hotkeys": {"seekStep": 15, "enableVolumeScroll": false, "alwaysCaptureHotkeys": true}, "videoJsResolutionSwitcher": { "ui": true, "default": "720p", "dynamicLabel": false } }, "customControlsOnMobile": true, "playbackRates": [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4] }'
>
<video
id=
"videoplayer"
style=
"width: 100%"
class=
"video-js vjs-default-skin vjs-big-play-centered"
width=
"640"
height=
"320"
controls
data-wasnotplayed=
"1"
data-setup=
'{ "language":"de", "plugins" : {"hotkeys": {"seekStep": 15, "enableVolumeScroll": false, "alwaysCaptureHotkeys": true}, "videoJsResolutionSwitcher": { "ui": true, "default": "720p", "dynamicLabel": false } }, "customControlsOnMobile": true, "playbackRates": [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75, 3, 3.25, 3.5, 3.75, 4] }'
>
{% for v in videos|sort(attribute='formats.player_prio', reverse=True) %}
{% for v in videos|sort(attribute='formats.player_prio', reverse=True) %}
<source
type=
"{{ v.mimetype }}"
src=
"{{ config.VIDEOPREFIX }}/{{ v.path }}"
data-label=
"{{ v.formats.description }}"
data-res=
"{{v.formats.resolution}}"
data-aspect=
"{{v.formats.aspect}}"
data-playerprio=
"{{v.formats.player_prio}}"
/>
<source
type=
"{{ v.
formats.
mimetype }}"
src=
"{{ config.VIDEOPREFIX }}/{{ v.path }}"
data-label=
"{{ v.formats.description }}"
data-res=
"{{v.formats.resolution}}"
data-aspect=
"{{v.formats.aspect}}"
data-player
_
prio=
"{{v.formats.player_prio}}"
/>
{{ v|safe }}
{{ v|safe }}
{% endfor %}
{% endfor %}
<track
srclang=
"de"
kind=
"chapters"
src=
"{{ url_for('chapters',lectureid=lecture.id) }}"
/>
<track
srclang=
"de"
kind=
"chapters"
src=
"{{ url_for('chapters',lectureid=lecture.id) }}"
/>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment