add video shortcode (#289)
* add video shortcode * Use "sampotts/plyr" library instead of "clappr/clappr" Signed-off-by: hossainemruz <hossainemruz@gmail.com> Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
This commit is contained in:
parent
d38634df8d
commit
6996894ec1
6 changed files with 32 additions and 5 deletions
|
@ -22,6 +22,7 @@
|
||||||
<link rel="stylesheet" href="{{ "/css/layouts/main.css" | relURL }}"/>
|
<link rel="stylesheet" href="{{ "/css/layouts/main.css" | relURL }}"/>
|
||||||
<link rel="stylesheet" href="{{ "/css/style.css" | relURL }}"/>
|
<link rel="stylesheet" href="{{ "/css/style.css" | relURL }}"/>
|
||||||
<link rel="stylesheet" href="{{ "/css/navigators/navbar.css" | relURL }}"/>
|
<link rel="stylesheet" href="{{ "/css/navigators/navbar.css" | relURL }}"/>
|
||||||
|
<link rel="stylesheet" href="{{ "/css/plyr.css" | relURL }}"/>
|
||||||
|
|
||||||
<!--=================== cdn ==============================-->
|
<!--=================== cdn ==============================-->
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Muli:wght@300;400;500;600" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css2?family=Muli:wght@300;400;500;600" rel="stylesheet">
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<script src="{{ "/js/jquery-3.4.1.min.js" | relURL }}"></script>
|
<script type="text/javascript" src="{{ "/js/jquery-3.4.1.min.js" | relURL }}"></script>
|
||||||
<script src="{{ "/js/popper.min.js" | relURL }}"></script>
|
<script type="text/javascript" src="{{ "/js/popper.min.js" | relURL }}"></script>
|
||||||
<script src="{{ "/js/bootstrap.min.js" | relURL }}"></script>
|
<script type="text/javascript" src="{{ "/js/bootstrap.min.js" | relURL }}"></script>
|
||||||
|
|
||||||
<script src="{{ "/js/navbar.js" | relURL }}"></script>
|
<script type="text/javascript" src="{{ "/js/navbar.js" | relURL }}"></script>
|
||||||
<script src="{{ "/js/main.js" | relURL }}"></script>
|
<script type="text/javascript" src="{{ "/js/plyr.js" | relURL }}"></script>
|
||||||
|
<script type="text/javascript" src="{{ "/js/main.js" | relURL }}"></script>
|
||||||
|
|
13
layouts/shortcodes/video.html
Normal file
13
layouts/shortcodes/video.html
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{{ $src := .Get "src" }}
|
||||||
|
{{ $type := .Get "type" }}
|
||||||
|
{{/*
|
||||||
|
A page can have multiple videos. We need to generate unique id for them.
|
||||||
|
Here, we are generating a sequence from 1 to 200 and taking the first element after a shuffle.
|
||||||
|
This will give a random number in most cases. However, if the page has many videos, we might have a collision.
|
||||||
|
We should find a better approach for doing this.
|
||||||
|
*/}}
|
||||||
|
{{ $randNumber := index (seq 200 | shuffle) 0 }}
|
||||||
|
|
||||||
|
<video class="video-player" id="video-{{ $randNumber }}" playsinline controls>
|
||||||
|
<source src="{{ $src }}" type="{{ $type | default "video/mp4" }}" />
|
||||||
|
</video>
|
1
static/css/plyr.css
Normal file
1
static/css/plyr.css
Normal file
File diff suppressed because one or more lines are too long
|
@ -72,6 +72,16 @@ var isMobile = false, isTablet = false, isLaptop = false;
|
||||||
}
|
}
|
||||||
addSmoothScroll();
|
addSmoothScroll();
|
||||||
|
|
||||||
|
// ===================== Video Player ==================
|
||||||
|
function renderVideoPlayer(){
|
||||||
|
var videos = document.getElementsByClassName("video-player");
|
||||||
|
for (var i =0; i< videos.length; i++ ){
|
||||||
|
const player = new Plyr("#"+videos[i].id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
renderVideoPlayer();
|
||||||
|
|
||||||
// re-render custom functions on window resize
|
// re-render custom functions on window resize
|
||||||
window.onresize = function () {
|
window.onresize = function () {
|
||||||
detectDevice();
|
detectDevice();
|
||||||
|
|
1
static/js/plyr.js
Normal file
1
static/js/plyr.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue