Skip to content

Commit

Permalink
Add code for task 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Bmorta committed Feb 6, 2024
1 parent fd473cd commit 742440d
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 0 deletions.
53 changes: 53 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
"url": "https://github.com/goitacademy/parcel-project-template/issues"
},
"dependencies": {
"@vimeo/player": "^2.21.0",
"lodash.throttle": "^4.1.1",
"modern-normalize": "^1.1.0",
"simplelightbox": "^2.14.2"
},
Expand Down
28 changes: 28 additions & 0 deletions src/js/02-video.js
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
import Player from '@vimeo/player';
import throttle from 'lodash.throttle';

const iframe = document.querySelector('#vimeo-player');
const player = new Player(iframe);


const handleThrottle = function (data) {
const timeInSeconds = data.seconds;
console.log(timeInSeconds);
localStorage.setItem('videoplayer-current-time', timeInSeconds);
};


player.on('timeupdate', throttle(handleThrottle, 1000));

player.setCurrentTime(localStorage.getItem('videoplayer-current-time')).then(function(seconds) {
// seconds = the actual time that the player seeked to
}).catch(function(error) {
switch (error.name) {
case 'RangeError':
// the time was less than 0 or greater than the video’s duration
break;

default:
// some other error occurred
break;
}
});

0 comments on commit 742440d

Please sign in to comment.