1212 * usage is here.
1313 *
1414 * To switch between types of media, specify the type attribute in media
15- * in the following format.
15+ * in the following format, otherwise known as MIME type .
1616 * <media type>/<media format>
1717 * examples: image/jpg, video/mp4, application/zip
1818
4444 </script>
4545
4646 ```
47-
47+ * For videos and images,
4848 * Note that default behavior is to mirror the size of the enclosing container.
4949 * You can, however, alter this in two ways.
5050 * 1. You can call `player.forceMax()` which will force the video or
5454 * or image and its enclosing container to the width and height you pass in.
5555 * Both such calls need to be made before the render call.
5656 *
57- * TODO: implement an abstraction to for the overlay rendering. Currently it
58- * is directly tied to a canvas. But, one can consider implementing this via
59- * div/DOM rendering and bringing the full power of CSS to bear on the
60- * overlays, including animation.
57+ * For zip files,
58+ * Note that the default behaviour is to have each image mirror the size of the
59+ * enclosing container.
60+ *
61+ * Also note that there are two options for rendering zip files,
62+ * Default: render as an image gallery.
63+ * SequenceFlag = true: render as a psuedo videoplayer.
6164 *
6265 * Copyright 2017-2019, Voxel51, Inc.
6366 * Jason Corso, jason@voxel51.com
@@ -76,8 +79,10 @@ import {
7679import {
7780 GalleryViewer ,
7881} from './galleryviewer.js' ;
82+ import {
83+ ImageSequence ,
84+ } from './imagesequence.js' ;
7985
80- // ES6 module export
8186export default Player51 ;
8287
8388
@@ -96,17 +101,22 @@ export default Player51;
96101 * In the case of images: Overlay can be a string pointing to a single URL.
97102 * @param {int } fps is the frame-rate of the media. If it is not provided
98103 * then it will be guessed. Ignore in the case of images.
99- *
104+ * @param {bool } sequenceFlag tells the player to render the zip file as either
105+ * an image gallery or a video player.
100106 */
101- function Player51 ( media , overlay , fps ) {
107+ function Player51 ( media , overlay , fps = 0 , sequenceFlag = false ) {
102108 this . mediaType = this . determineMediaType ( media ) ;
103109 // Load correct player
104110 if ( this . mediaType === 'video' ) {
105111 this . player = new VideoPlayer ( media , overlay , fps ) ;
106112 } else if ( this . mediaType === 'image' ) {
107113 this . player = new ImageViewer ( media , overlay ) ;
108- } else if ( this . mediaType === 'gallery' || this . mediaType === 'application' ) {
109- this . player = new GalleryViewer ( media , overlay ) ;
114+ } else if ( this . mediaType === 'application' && this . mediaFormat === 'zip' ) {
115+ if ( sequenceFlag ) {
116+ this . player = new ImageSequence ( media , overlay , fps ) ;
117+ } else {
118+ this . player = new GalleryViewer ( media , overlay ) ;
119+ }
110120 } else {
111121 /* eslint-disable-next-line no-console */
112122 console . log ( 'WARN: Player51 doesn\'t support this media type yet.' ) ;
@@ -136,6 +146,19 @@ Player51.prototype.setBoolDrawFrameNumber = function(value) {
136146} ;
137147
138148
149+ /**
150+ * This function sets player.renderer.reader.workerScriptsPath
151+ *
152+ * @member setZipLibraryParameters
153+ * @param {string } path relative to zip.js
154+ */
155+ Player51 . prototype . setZipLibraryParameters = function ( path ) {
156+ if ( this . player . renderer ) {
157+ this . player . renderer . reader . workerScriptsPath = path ;
158+ }
159+ } ;
160+
161+
139162/**
140163 * This function figures out the type of media to be rendered.
141164 *
@@ -148,6 +171,7 @@ Player51.prototype.determineMediaType = function(media) {
148171 if ( splitResults . length !== 2 ) {
149172 throw new Error ( 'Media type is incorrect.' ) ;
150173 }
174+ this . mediaFormat = splitResults [ 1 ] ;
151175 return splitResults [ 0 ] ;
152176} ;
153177
0 commit comments