const videoUtils = { VIDEO_TYPE_VIMEO: "VIDEO_TYPE_VIMEO", VIDEO_TYPE_BLOB: "VIDEO_TYPE_BLOB", getVideoType: function getVideoType(lensId) { // given a lens id, this function returns the type of video // possible values: // VIDEO_TYPE_VIMEO // VIDEO_TYPE_BLOB log('getVideoType: enter'); log('getVideoType: lensId=' + lensId); // NOTE: for now, all videos are Vimeo log('getVideoType: STUB. for now, all videos are Vimeo.'); log('getVideoType: leave'); return videoUtils.VIDEO_TYPE_VIMEO; //if ((lensId === 13) || (lensId === 6) || (lensId === 20)) { // // if it's a lens for which we use a Vimeo iFrame // log('getVideoType: video type=' + videoUtils.VIDEO_TYPE_VIMEO); // log('getVideoType: leave'); // return videoUtils.VIDEO_TYPE_VIMEO; //} //log('getVideoType: video type=' + videoUtils.VIDEO_TYPE_BLOB); //log('getVideoType: leave'); //return videoUtils.VIDEO_TYPE_BLOB; //// otherwise, for now, it's blob }, getVideoHtml_video: function getVideoHtml_video(lensId, videoElemWidth, videoElemHeight, videoUrl) { const logHdr = 'getVideoHtml_video: '; log(logHdr + 'enter'); log(logHdr + 'lensId=' + lensId); log(logHdr + 'videoElemWidth=' + videoElemWidth); log(logHdr + 'videoElemHeight=' + videoElemHeight); log(logHdr + 'videoUrl=' + videoUrl); // NOTE: to include buttons to play video, add "controls" attribute to the video element below // NOTE: to enable iphone-inline-video, add playsineline attribute to the video element const videoId = elemIdUtils.getVideoElemId(lensId); // get a unique id for the video element log('getVideoHtml_video: videoId=' + videoId); const videoHtml = '<video id="' + videoId + '" width="' + videoElemWidth + '" height="' + videoElemHeight + '" src="' + videoUrl + '" type="video/mp4" controls><p>Your browser does not support the video tag.</p></video>'; log(logHdr + 'leave'); return videoHtml; }, getVideoHtml_iFrame: function getVideoHtml_iFrame(lensId, videoElemWidth, videoElemHeight, iFrameUrl) { log('getVideoHtml_iFrame: enter'); log('getVideoHtml_iFrame: lensId=' + lensId); log('getVideoHtml_iFrame: videoElemWidth=' + videoElemWidth); log('getVideoHtml_iFrame: videoElemHeight=' + videoElemHeight); log('getVideoHtml_iFrame: iFrameUrl=' + iFrameUrl); const divId = elemIdUtils.getVideoIFrameParentElemId(lensId); // get an id for the div parent of the video iFrame log('getVideoHtml_iFrame: divId=' + divId); const iFrameId = elemIdUtils.getVideoIFrameElemId(lensId); // get an id for the video iFrame log('getVideoHtml_iFrame: iFrameId=' + iFrameId); const videoHtml = '<div id="' + divId + '" width="' + videoElemWidth + '" height="' + videoElemHeight + '" class="embed-responsive embed-responsive-16by9 video-parent"><iframe id="' + iFrameId + '" class="embed-responsive-item vimeo-iframe" src="' + iFrameUrl + '" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe></div>'; log('getVideoHtml_iFrame: leave'); return videoHtml; }, getVideoUrl: function getVideoUrl(lensId) { log('getVideoUrl: enter'); log('getVideoUrl: lensId=' + lensId); const zIndex = (lensId - 1); // array indices are zero-based const lensDTO = lensDTOs[zIndex]; const theUrl = lensDTO.VideoUrl; log('getVideoUrl: theUrl=' + theUrl); log('getVideoUrl: leave'); return theUrl; }, getIFrameUrl: function getIFrameUrl(lensId) { log('getIFrameUrl: enter'); log('getIFrameUrl: lensId=' + lensId); const zIndex = (lensId - 1); // array indices are zero-based const lensDTO = lensDTOs[zIndex]; const theUrl = lensDTO.IFrameUrl; log('getIFrameUrl: theUrl=' + theUrl); log('getIFrameUrl: leave'); return theUrl; }, getVideoElemSize: function getVideoElemSize(viewWidth, viewHeight) { const logHdr = 'getVideoElemSize: '; log(logHdr + 'enter'); log(logHdr + 'viewWidth=' + viewWidth); log(logHdr + 'viewHeight=' + viewHeight); var sizeObj = {}; var elemWidth = 260; var elemHeight = 146; // default to smallest size if (viewWidth > 320) { elemWidth = 300; elemHeight = 168; } if (viewWidth > 425) { if (viewHeight > 414) { // if the view is taller than iPhone 6 in landscape mode elemWidth = 565; elemHeight = 317; } } sizeObj.width = elemWidth; sizeObj.height = elemHeight; log(logHdr + 'elemWidth=' + elemWidth); log(logHdr + 'elemHeight=' + elemHeight); log(logHdr + 'leave'); return sizeObj; } };