Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
reindernijhoff committed Mar 27, 2024
1 parent 7bb8780 commit 204fe29
Show file tree
Hide file tree
Showing 528 changed files with 648 additions and 574 deletions.
84 changes: 77 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,102 @@ import { FastImageSequence } from '@mediamonks/fast-image-sequence';

const options = {
frames: 100,
wrap: true,
size: 'cover',
imageURLCallback: (index) => `path/to/your/image/sequence/image${index}.jpg`,

tarURL: 'path/to/your/tar/file.tar',
tarImageURLCallback: (index) => `image${index}.jpg`,

wrap: true,
size: 'cover',
};

const sequence = new FastImageSequence(containerElement, options);
sequence.play();
```

In the options object, you need to set either imageURLCallback or tarImageURLCallback. Both are optional, but at least one must be set. If you use tarImageURLCallback, you also have to load a tar file.
In the options object, you need to set either imageURLCallback or tarImageURLCallback. **Both are optional, but at least one must be set.** If you use tarImageURLCallback, you also have to load a tar file.

Normally you will only add the tar with preview images for large images sequences. Note that you don't have to include all images in the tar. It will still work if you, for example, only include every 4th image of the sequence. This way you can reduce the size of the tar file significantly.

The imageURLCallback and tarImageURLCallback are functions that take an index as a parameter and return a string representing the URL of the image at that index in the sequence. This allows you to dynamically generate the URLs of your images based on their index in the sequence.

The normal usage of this library involves having a tar file with low-resolution preview images. These will be used when you randomly seek or jump in the sequence or the internet speed is low. However, you are free to fine-tune as you will. For example, you can only use the tar with high-resolution images.
The normal usage of this library involves having a tar file with low-resolution preview images. These will be used when you randomly seek or jump in the sequence or the internet speed is low. However, you are free to fine-tune as you will. For example, you can also use a tar with high-resolution images and don't set an imageURLCallback. This way, all images will served from the tar-file, which will reduce the number of requests and speed up the loading time.

By setting callbacks for URLs and loading the tar file yourself, you can set different functions for different devices and/or different supported image file formats. This allows you to optimize the image sequence for your specific project needs.

This library allows you to control the playback of the image sequence, stop it, get the current progress, and more.
```ts
## Methods

The following methods are available for an FastImageSequence object:

### tick(func: (dt: number) => void)

This method registers a tick function to be called on every frame update.

```typescript
sequence.tick(func);
```

- `func` is a function that will be called on every frame update.

### play(fps: number = 30)

This method starts playing the image sequence at a specified frame rate.

```typescript
sequence.play(fps);
```

- `fps` is an optional parameter determining the frame rate at which to play the sequence. If not provided, it defaults to `30`. Note that the fps can also be negative, which will play the sequence in reverse.

### stop()

This method stops playing the image sequence.

```typescript
sequence.stop();
console.log(sequence.progress);
```

### isPlaying

This is a getter method that returns a boolean indicating whether the image sequence is playing.

```typescript
const playingStatus = sequence.isPlaying;
```

### isPaused

This is a getter method that returns a boolean indicating whether the image sequence is paused.

```typescript
const pausedStatus = sequence.isPaused;
```

### progress

This is a getter and setter method that gets or sets the current progress (0-1) of the image sequence.

```typescript
// Get the progress
const currentProgress = sequence.progress;

// Set the progress
sequence.progress = value;
```

- `value` is a number that sets the current progress of the image sequence.

### getFrameImage(index: number): Promise<HTMLImageElement | ImageBitmap>

This method gets the image of a specific frame and returns a Promise that resolves with the image of the frame.

```typescript
sequence.getFrameImage(index);
```

- `index` is the index of the frame to get the image from.


## Creating a Tarball with Preview Images

A tarball is a collection of files and directories stored in a single file. In the context of `FastImageSequence`, you can use a tarball to store low-resolution preview images for your image sequence. This can be particularly useful when you want to seek or jump in the sequence quickly or when the internet speed is low.
Expand Down
8 changes: 4 additions & 4 deletions example/package-lock.json

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

3 changes: 1 addition & 2 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"vite": "^5.1.6"
},
"dependencies": {
"@mediamonks/fast-image-sequence": "^0.0.2",
"stats.js": "^0.17.0"
"@mediamonks/fast-image-sequence": "^0.1.0"
}
}
Binary file added example/public/0001.webp
Binary file not shown.
Binary file added example/public/0002.webp
Binary file not shown.
Binary file added example/public/0003.webp
Binary file not shown.
Binary file added example/public/0004.webp
Binary file not shown.
Binary file added example/public/0005.webp
Binary file not shown.
Binary file added example/public/0006.webp
Binary file not shown.
Binary file added example/public/0007.webp
Binary file not shown.
Binary file added example/public/0008.webp
Binary file not shown.
Binary file added example/public/0009.webp
Binary file not shown.
Binary file added example/public/0010.webp
Binary file not shown.
Binary file added example/public/0011.webp
Binary file not shown.
Binary file added example/public/0012.webp
Binary file not shown.
Binary file added example/public/0013.webp
Binary file not shown.
Binary file added example/public/0014.webp
Binary file not shown.
Binary file added example/public/0015.webp
Binary file not shown.
Binary file added example/public/0016.webp
Binary file not shown.
Binary file added example/public/0017.webp
Binary file not shown.
Binary file added example/public/0018.webp
Binary file not shown.
Binary file added example/public/0019.webp
Binary file not shown.
Binary file added example/public/0020.webp
Binary file not shown.
Binary file added example/public/0021.webp
Binary file not shown.
Binary file added example/public/0022.webp
Binary file not shown.
Binary file added example/public/0023.webp
Binary file not shown.
Binary file added example/public/0024.webp
Binary file not shown.
Binary file added example/public/0025.webp
Binary file not shown.
Binary file added example/public/0026.webp
Binary file not shown.
Binary file added example/public/0027.webp
Binary file not shown.
Binary file added example/public/0028.webp
Binary file not shown.
Binary file added example/public/0029.webp
Binary file not shown.
Binary file added example/public/0030.webp
Binary file not shown.
Binary file added example/public/0031.webp
Binary file not shown.
Binary file added example/public/0032.webp
Binary file not shown.
Binary file added example/public/0033.webp
Binary file not shown.
Binary file added example/public/0034.webp
Binary file not shown.
Binary file added example/public/0035.webp
Binary file not shown.
Binary file added example/public/0036.webp
Binary file not shown.
Binary file added example/public/0037.webp
Binary file not shown.
Binary file added example/public/0038.webp
Binary file not shown.
Binary file added example/public/0039.webp
Binary file not shown.
Binary file added example/public/0040.webp
Binary file not shown.
Binary file added example/public/0041.webp
Binary file not shown.
Binary file added example/public/0042.webp
Binary file not shown.
Binary file added example/public/0043.webp
Binary file not shown.
Binary file added example/public/0044.webp
Binary file not shown.
Binary file added example/public/0045.webp
Binary file not shown.
Binary file added example/public/0046.webp
Binary file not shown.
Binary file added example/public/0047.webp
Binary file not shown.
Binary file added example/public/0048.webp
Binary file not shown.
Binary file added example/public/0049.webp
Binary file not shown.
Binary file added example/public/0050.webp
Binary file not shown.
Binary file added example/public/0051.webp
Binary file not shown.
Binary file added example/public/0052.webp
Binary file not shown.
Binary file added example/public/0053.webp
Binary file not shown.
Binary file added example/public/0054.webp
Binary file not shown.
Binary file added example/public/0055.webp
Binary file not shown.
Binary file added example/public/0056.webp
Binary file not shown.
Binary file added example/public/0057.webp
Binary file not shown.
Binary file added example/public/0058.webp
Binary file not shown.
Binary file added example/public/0059.webp
Binary file not shown.
Binary file added example/public/0060.webp
Binary file not shown.
Binary file added example/public/0061.webp
Binary file not shown.
Binary file added example/public/0062.webp
Binary file not shown.
Binary file added example/public/0063.webp
Binary file not shown.
Binary file added example/public/0064.webp
Binary file not shown.
Binary file added example/public/0065.webp
Binary file not shown.
Binary file added example/public/0066.webp
Binary file not shown.
Binary file added example/public/0067.webp
Binary file not shown.
Binary file added example/public/0068.webp
Binary file not shown.
Binary file added example/public/0069.webp
Binary file not shown.
Binary file added example/public/0070.webp
Binary file not shown.
Binary file added example/public/0071.webp
Binary file not shown.
Binary file added example/public/0072.webp
Binary file not shown.
Binary file added example/public/0073.webp
Binary file not shown.
Binary file added example/public/0074.webp
Binary file not shown.
Binary file added example/public/0075.webp
Binary file not shown.
Binary file added example/public/0076.webp
Binary file not shown.
Binary file added example/public/0077.webp
Binary file not shown.
Binary file added example/public/0078.webp
Binary file not shown.
Binary file added example/public/0079.webp
Binary file not shown.
Binary file added example/public/0080.webp
Binary file not shown.
Binary file added example/public/0081.webp
Binary file not shown.
Binary file added example/public/0082.webp
Binary file not shown.
Binary file added example/public/0083.webp
Binary file not shown.
Binary file added example/public/0084.webp
Binary file not shown.
Binary file added example/public/0085.webp
Binary file not shown.
Binary file added example/public/0086.webp
Binary file not shown.
Binary file added example/public/0087.webp
Binary file not shown.
Binary file added example/public/0088.webp
Binary file not shown.
Binary file added example/public/0089.webp
Binary file not shown.
Binary file added example/public/0090.webp
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 204fe29

Please sign in to comment.