### Getting Started Example
Source: https://github.com/videojs/http-streaming/blob/main/README.md
Example of how to include videojs-http-streaming in a page when a specific combination of Video.js and VHS versions is needed.
```html
```
--------------------------------
### Development Setup
Source: https://github.com/videojs/http-streaming/blob/main/CONTRIBUTING.md
Steps to set up the development environment, including installing dependencies and starting the development server.
```bash
npm install
npm start
```
--------------------------------
### Install project dependencies
Source: https://github.com/videojs/http-streaming/blob/main/COLLABORATOR_GUIDE.md
Installs the necessary dependencies for the project.
```sh
npm install
```
--------------------------------
### Install Node.js version
Source: https://github.com/videojs/http-streaming/blob/main/COLLABORATOR_GUIDE.md
Installs the Node.js version specified in the .nvmrc file.
```sh
nvm install
```
--------------------------------
### Migrating hls-gap-skip event listener
Source: https://github.com/videojs/http-streaming/blob/main/docs/migration-2-3.md
Example demonstrating the change from listening to 'hls-gap-skip' to 'vhs-gap-skip'.
```javascript
player.tech().on('hls-gap-skip', () => {
console.log('a gap has been skipped');
});
```
```javascript
player.tech().on('vhs-gap-skip', () => {
console.log('a gap has been skipped');
});
```
--------------------------------
### Install videojs-http-streaming with npm
Source: https://github.com/videojs/http-streaming/blob/main/README.md
To install `videojs-http-streaming` with npm, run
```bash
npm install --save @videojs/http-streaming
```
--------------------------------
### Examples of Player Time to Program Time Conversion
Source: https://github.com/videojs/http-streaming/blob/main/docs/program-time-from-player-time.md
Illustrative examples demonstrating the usage of the `playerTimeToProgramTime` function with different segment data and player times, showing the resulting program times.
```javascript
// Program Times:
// segment1: 2018-11-10T00:00:30.1Z => 2018-11-10T00:00:32.1Z
// segment2: 2018-11-10T00:00:32.1Z => 2018-11-10T00:00:34.1Z
// segment3: 2018-11-10T00:00:34.1Z => 2018-11-10T00:00:36.1Z
//
// Player Times:
// segment1: 0 => 2
// segment2: 2 => 4
// segment3: 4 => 6
const segment1 = {
dateTimeObject: 2018-11-10T00:00:30.1Z
videoTimingInfo: {
transmuxerPrependedSeconds: 0,
transmuxedPresentationStart: 0
}
};
playerTimeToProgramTime(0.1, segment1);
// startOfSegment = 0 + 0 = 0
// offsetFromSegmentStart = 0.1 - 0 = 0.1
// return 2018-11-10T00:00:30.1Z + 0.1 = 2018-11-10T00:00:30.2Z
const segment2 = {
dateTimeObject: 2018-11-10T00:00:32.1Z
videoTimingInfo: {
transmuxerPrependedSeconds: 0.3,
transmuxedPresentationStart: 1.7
}
};
playerTimeToProgramTime(2.5, segment2);
// startOfSegment = 1.7 + 0.3 = 2
// offsetFromSegmentStart = 2.5 - 2 = 0.5
// return 2018-11-10T00:00:32.1Z + 0.5 = 2018-11-10T00:00:32.6Z
const segment3 = {
dateTimeObject: 2018-11-10T00:00:34.1Z
videoTimingInfo: {
transmuxerPrependedSeconds: 0.2,
transmuxedPresentationStart: 3.8
}
};
playerTimeToProgramTime(4, segment3);
// startOfSegment = 3.8 + 0.2 = 4
// offsetFromSegmentStart = 4 - 4 = 0
// return 2018-11-10T00:00:34.1Z + 0 = 2018-11-10T00:00:34.1Z
```
--------------------------------
### Caption Services Example
Source: https://github.com/videojs/http-streaming/blob/main/README.md
An example demonstrating how to configure caption services.
```javascript
{
vhs: {
captionServices: {
CC1: {
language: 'en',
label: 'English'
},
SERVICE1: {
langauge: 'kr',
label: 'Korean',
encoding: 'euc-kr'
default: true,
}
}
}
}
```
--------------------------------
### m3u8 layout example
Source: https://github.com/videojs/http-streaming/blob/main/docs/multiple-alternative-audio-tracks.md
An example of how audio tracks might be represented in an m3u8 manifest.
```javascript
{
'media-group-1': [{
'audio-track-1': {
default: true,
lang: 'eng'
},
'audio-track-2': {
default: false,
lang: 'fr'
},
'audio-track-3': {
default: false,
lang: 'eng',
characteristics: 'public.accessibility.describes-video'
}
}]
}
```
--------------------------------
### HTML Video Tag Example
Source: https://github.com/videojs/http-streaming/wiki/A-Walk-Through-VHS
An example of an HTML