UNPKG

4.13 kBTypeScriptView Raw
1/**
2 * Video module for lightGallery
3 * Supports HTML5, YouTube, Vimeo, wistia videos
4 *
5 *
6 * @ref Wistia
7 * https://wistia.com/support/integrations/wordpress(How to get url)
8 * https://wistia.com/support/developers/embed-options#using-embed-options
9 * https://wistia.com/support/developers/player-api
10 * https://wistia.com/support/developers/construct-an-embed-code
11 * http://jsfiddle.net/xvnm7xLm/
12 * https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video
13 * https://wistia.com/support/embed-and-share/sharing-videos
14 * https://private-sharing.wistia.com/medias/mwhrulrucj
15 *
16 * @ref Youtube
17 * https://developers.google.com/youtube/player_parameters#enablejsapi
18 * https://developers.google.com/youtube/iframe_api_reference
19 * https://developer.chrome.com/blog/autoplay/#iframe-delegation
20 *
21 * @ref Vimeo
22 * https://stackoverflow.com/questions/10488943/easy-way-to-get-vimeo-id-from-a-vimeo-url
23 * https://vimeo.zendesk.com/hc/en-us/articles/360000121668-Starting-playback-at-a-specific-timecode
24 * https://vimeo.zendesk.com/hc/en-us/articles/360001494447-Using-Player-Parameters
25 */
26import { LightGallery } from '../../lightgallery';
27import { lgQuery } from '../../lgQuery';
28import { CustomEventAfterSlide, CustomEventHasVideo, CustomEventSlideItemLoad } from '../../types';
29import { VideoSource } from './types';
30declare global {
31 interface Window {
32 _wq: any;
33 Vimeo: any;
34 }
35}
36export default class Video {
37 private core;
38 private settings;
39 constructor(instance: LightGallery);
40 init(): void;
41 /**
42 * @desc Event triggered when a slide is completely loaded
43 *
44 * @param {Event} event - lightGalley custom event
45 */
46 onSlideItemLoad(event: CustomEventSlideItemLoad): void;
47 /**
48 * @desc Event triggered when video url or poster found
49 * Append video HTML is poster is not given
50 * Play if autoplayFirstVideo is true
51 *
52 * @param {Event} event - Javascript Event object.
53 */
54 onHasVideo(event: CustomEventHasVideo): void;
55 /**
56 * @desc fired immediately before each slide transition.
57 * Pause the previous video
58 * Hide the download button if the slide contains YouTube, Vimeo, or Wistia videos.
59 *
60 * @param {Event} event - Javascript Event object.
61 * @param {number} prevIndex - Previous index of the slide.
62 * @param {number} index - Current index of the slide
63 */
64 onBeforeSlide(event: CustomEvent): void;
65 /**
66 * @desc fired immediately after each slide transition.
67 * Play video if autoplayVideoOnSlide option is enabled.
68 *
69 * @param {Event} event - Javascript Event object.
70 * @param {number} prevIndex - Previous index of the slide.
71 * @param {number} index - Current index of the slide
72 * @todo should check on onSlideLoad as well if video is not loaded on after slide
73 */
74 onAfterSlide(event: CustomEventAfterSlide): void;
75 loadAndPlayVideo(index: number): void;
76 /**
77 * Play HTML5, Youtube, Vimeo or Wistia videos in a particular slide.
78 * @param {number} index - Index of the slide
79 */
80 playVideo(index: number): void;
81 /**
82 * Pause HTML5, Youtube, Vimeo or Wistia videos in a particular slide.
83 * @param {number} index - Index of the slide
84 */
85 pauseVideo(index: number): void;
86 getVideoHtml(src: any, addClass: any, index: number, html5Video: VideoSource): string;
87 /**
88 * @desc - Append videos to the slide
89 *
90 * @param {HTMLElement} el - slide element
91 * @param {Object} videoParams - Video parameters, Contains src, class, index, htmlVideo
92 */
93 appendVideos(el: lgQuery, videoParams: {
94 src: string;
95 addClass: string;
96 index: number;
97 html5Video: any;
98 }): any;
99 gotoNextSlideOnVideoEnd(src: any, index: number): void;
100 controlVideo(index: number, action: string): void;
101 loadVideoOnPosterClick($el: lgQuery, forcePlay?: boolean): void;
102 onVideoLoadAfterPosterClick($el: lgQuery, index: number): void;
103 destroy(): void;
104}