From 660c332c61601cbbdf1b1e47adc69b2477bc8291 Mon Sep 17 00:00:00 2001 From: Dan Niles <56271899+dan-niles@users.noreply.github.com> Date: Tue, 18 Jun 2024 10:07:44 +0530 Subject: [PATCH] Setup video.js and add video player page --- CHANGELOG | 2 + zimui/cypress/e2e/video_player_page.cy.ts | 25 +++ .../channel/videos/timelapse-9Tgo.json | 19 ++ zimui/package.json | 4 +- zimui/src/App.vue | 6 + zimui/src/assets/vjs-youtube.css | 49 +++++ zimui/src/components/video/VideoPlayer.vue | 38 ++++ .../video/player/VideoChannelInfo.vue | 40 ++++ .../video/player/VideoDescription.vue | 19 ++ .../video/player/VideoTitleInfo.vue | 23 ++ zimui/src/plugins/webp-hero.ts | 11 + zimui/src/types/Channel.ts | 2 + zimui/src/views/VideoPlayerView.vue | 71 ++++++- zimui/yarn.lock | 200 ++++++++++++++++++ 14 files changed, 504 insertions(+), 5 deletions(-) create mode 100644 zimui/cypress/e2e/video_player_page.cy.ts create mode 100644 zimui/cypress/fixtures/channel/videos/timelapse-9Tgo.json create mode 100644 zimui/src/assets/vjs-youtube.css create mode 100644 zimui/src/components/video/VideoPlayer.vue create mode 100644 zimui/src/components/video/player/VideoChannelInfo.vue create mode 100644 zimui/src/components/video/player/VideoDescription.vue create mode 100644 zimui/src/components/video/player/VideoTitleInfo.vue create mode 100644 zimui/src/plugins/webp-hero.ts diff --git a/CHANGELOG b/CHANGELOG index 19d32065..d7f4a259 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Remove old UI files and methods: template files (home.html, article.html) and `make_html_files` method in scraper.py - Remove `--locale` arg, broken locale folder, files used for translation; translation will be restored with #222 - Create "Videos" and "Playlists" tabs for homepage in new Vue.js UI (#213, #214) +- Create video player page in new Vue.js UI (#215) +- Add support for variable playback speed in video player (#174) ## [2.3.0] - 2024-05-22 diff --git a/zimui/cypress/e2e/video_player_page.cy.ts b/zimui/cypress/e2e/video_player_page.cy.ts new file mode 100644 index 00000000..93085a83 --- /dev/null +++ b/zimui/cypress/e2e/video_player_page.cy.ts @@ -0,0 +1,25 @@ +describe('video player page', () => { + beforeEach(() => { + cy.intercept('GET', '/channel.json', { fixture: 'channel/channel.json' }).as('getChannel') + cy.intercept('GET', '/playlists/uploads_from_openzim_testing-917Q.json', { + fixture: 'channel/playlists/uploads_from_openzim_testing-917Q.json' + }).as('getUploads') + cy.visit('/') + cy.wait('@getChannel') + cy.wait('@getUploads') + }) + + it('loads the video and related information', () => { + cy.intercept('GET', '/videos/timelapse-9Tgo.json', { + fixture: 'channel//videos/timelapse-9Tgo.json' + }).as('getVideo') + cy.contains('.v-card-title ', 'Timelapse').click() + cy.wait('@getVideo') + + cy.url().should('include', '/watch') + cy.contains('.video-title', 'Timelapse') + cy.contains('.video-date', 'Published on Jun 4, 2024') + cy.contains('.video-channel', 'openZIM_testing') + cy.contains('.video-description', 'This is a short video of a timelapse.') + }) +}) diff --git a/zimui/cypress/fixtures/channel/videos/timelapse-9Tgo.json b/zimui/cypress/fixtures/channel/videos/timelapse-9Tgo.json new file mode 100644 index 00000000..f210513f --- /dev/null +++ b/zimui/cypress/fixtures/channel/videos/timelapse-9Tgo.json @@ -0,0 +1,19 @@ +{ + "id": "9TgosbGRsTk", + "title": "Timelapse", + "description": "This is a short video of a timelapse.", + "author": { + "channelId": "UC8elThf5TGMpQfQc_VE917Q", + "channelTitle": "openZIM_testing", + "channelDescription": "", + "channelJoinedDate": "2024-06-04T13:30:16.232286Z", + "profilePath": "channels/UC8elThf5TGMpQfQc_VE917Q/profile.jpg", + "bannerPath": "channels/UC8elThf5TGMpQfQc_VE917Q/banner.jpg" + }, + "publicationDate": "2024-06-04T14:57:45Z", + "videoPath": "videos/9TgosbGRsTk/video.webm", + "thumbnailPath": "videos/9TgosbGRsTk/video.webp", + "subtitlePath": null, + "subtitleList": [], + "duration": "PT11S" +} diff --git a/zimui/package.json b/zimui/package.json index 3df29f35..160b5c48 100644 --- a/zimui/package.json +++ b/zimui/package.json @@ -18,10 +18,12 @@ "axios": "^1.7.2", "dayjs": "^1.11.11", "pinia": "^2.1.7", + "video.js": "^8.12.0", "vite-plugin-vuetify": "^2.0.3", "vue": "^3.4.21", "vue-router": "^4.3.0", - "vuetify": "^3.6.7" + "vuetify": "^3.6.7", + "webp-hero": "^0.0.2" }, "devDependencies": { "@mdi/font": "^7.4.47", diff --git a/zimui/src/App.vue b/zimui/src/App.vue index 1cce9374..aa9b6181 100644 --- a/zimui/src/App.vue +++ b/zimui/src/App.vue @@ -1,10 +1,16 @@