Skip to content

Commit 00596cc

Browse files
author
Rob Walch
committed
Merge master into feature/v1.0.0
2 parents 3d6be17 + 9a5ebf1 commit 00596cc

File tree

10 files changed

+306
-64
lines changed

10 files changed

+306
-64
lines changed

.travis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ env:
1212
- SAUCE_USERNAME=mangui
1313
stages:
1414
- buildAndTest
15-
- releaseCanary
15+
- releaseAlpha
1616
- release
1717
- testFuncRequired
1818
- testFuncOptional
@@ -39,10 +39,10 @@ jobs:
3939
skip_cleanup: true
4040
on:
4141
tags: true
42-
# publish canary package (and deploy gh-pages) if on master
43-
- stage: releaseCanary
42+
# publish canary package if on master
43+
- stage: releaseAlpha
4444
if: branch = master AND type != pull_request
45-
env: TRAVIS_MODE=releaseCanary
45+
env: TRAVIS_MODE=releaseAlpha
4646
# Required tests
4747
- stage: buildAndTest
4848
env: TRAVIS_MODE=build

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![Build Status](https://api.travis-ci.org/video-dev/hls.js.svg?branch=master)](https://travis-ci.org/video-dev/hls.js)
22
[![npm](https://img.shields.io/npm/v/hls.js.svg?style=flat)](https://npmjs.org/package/hls.js)
3-
[![npm](https://img.shields.io/npm/v/hls.js/canary.svg?style=flat)](https://www.npmjs.com/package/hls.js/v/canary)
3+
[![npm](https://img.shields.io/npm/v/hls.js/alpha.svg?style=flat)](https://www.npmjs.com/package/hls.js/v/alpha)
44
[![](https://data.jsdelivr.com/v1/package/npm/hls.js/badge?style=rounded)](https://www.jsdelivr.com/package/npm/hls.js)
55

66
[![](https://www.netlify.com/img/global/badges/netlify-color-accent.svg)](https://www.netlify.com)
@@ -58,8 +58,8 @@ Find the commit on [https://github.com/video-dev/hls.js/blob/deployments/README.
5858

5959
```html
6060
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
61-
<!-- Or if you want a more recent canary version -->
62-
<!-- <script src="https://cdn.jsdelivr.net/npm/hls.js@canary"></script> -->
61+
<!-- Or if you want a more recent alpha version -->
62+
<!-- <script src="https://cdn.jsdelivr.net/npm/hls.js@alpha"></script> -->
6363
<video id="video"></video>
6464
<script>
6565
var video = document.getElementById('video');
@@ -147,9 +147,9 @@ If you want to bundle the application yourself, use node
147147
```
148148
npm install hls.js
149149
```
150-
or for the version from master (canary)
150+
or for the version from master (alpha)
151151
```
152-
npm install hls.js@canary
152+
npm install hls.js@alpha
153153
```
154154

155155
**NOTE:** `hls.light.*.js` dist files do not include subtitling and alternate-audio features.

demo/chart/timeline-chart.ts

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class TimelineChart {
9090
scale.options.ticks.min = 0;
9191
scale.options.ticks.max = 60;
9292
const config = this.chart.config;
93-
if (config && config.options) {
93+
if (config?.options) {
9494
config.options.plugins.zoom.zoom.rangeMax.x = 60;
9595
}
9696
labels.length = 0;
@@ -112,7 +112,7 @@ export class TimelineChart {
112112
if (this.hidden) {
113113
return;
114114
}
115-
if (datasets && datasets.length) {
115+
if (datasets?.length) {
116116
const scale = this.chart.scales[X_AXIS_SECONDS];
117117
const { top } = this.chart.chartArea;
118118
const height = top + datasets.reduce((val, dataset) => val + dataset.barThickness, 0) + scale.height + 5;
@@ -195,7 +195,7 @@ export class TimelineChart {
195195
const { targetduration, totalduration, url } = details;
196196
const { datasets } = this.chart.data;
197197
// eslint-disable-next-line no-restricted-properties
198-
const levelDataSet = datasets.find(dataset => dataset.url && dataset.url.toString() === url);
198+
const levelDataSet = arrayFind(datasets, dataset => dataset.url && dataset.url.toString() === url);
199199
if (!levelDataSet) {
200200
return;
201201
}
@@ -238,7 +238,7 @@ export class TimelineChart {
238238
set maxZoom (x: number) {
239239
const { chart } = this;
240240
const { config } = chart;
241-
if (config && config.options) {
241+
if (config?.options) {
242242
const currentZoom = config.options.plugins.zoom.zoom.rangeMax.x;
243243
const newZoom = Math.max(x, currentZoom);
244244
if (currentZoom === 60 && newZoom !== currentZoom) {
@@ -252,13 +252,12 @@ export class TimelineChart {
252252
updateFragment (data: any) {
253253
const { datasets } = this.chart.data;
254254
const frag: Fragment = data.frag;
255-
// eslint-disable-next-line no-restricted-properties
256-
const levelDataSet = datasets.find(dataset => dataset.url === frag.baseurl);
255+
const levelDataSet = arrayFind(datasets, dataset => dataset.url === frag.baseurl);
257256
if (!levelDataSet) {
258257
return;
259258
}
260259
// eslint-disable-next-line no-restricted-properties
261-
const fragData = levelDataSet.data.find(fragData => fragData.relurl === frag.relurl);
260+
const fragData = arrayFind(levelDataSet.data, fragData => fragData.relurl === frag.relurl);
262261
if (fragData && fragData !== frag) {
263262
Object.assign(fragData, frag);
264263
}
@@ -631,3 +630,20 @@ function getChartOptions () {
631630
}
632631
};
633632
}
633+
634+
function arrayFind (array, predicate) {
635+
const len = array.length >>> 0;
636+
if (typeof predicate !== 'function') {
637+
throw TypeError('predicate must be a function');
638+
}
639+
const thisArg = arguments[2];
640+
let k = 0;
641+
while (k < len) {
642+
const kValue = array[k];
643+
if (predicate.call(thisArg, kValue, k, array)) {
644+
return kValue;
645+
}
646+
k++;
647+
}
648+
return undefined;
649+
}

demo/main.js

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
/* global $, Hls */
1+
/* global $, Hls, __NETLIFY__ */
22
/* eslint camelcase: 0 */
33

44
import { sortObject, copyTextToClipboard } from './demo-utils';
55
import { TimelineChart } from './chart/timeline-chart';
66

7+
const NETLIFY = __NETLIFY__; // replaced in build
8+
79
const STORAGE_KEYS = {
810
Editor_Persistence: 'hlsjs:config-editor-persist',
911
Hls_Config: 'hlsjs:config'
@@ -110,8 +112,27 @@ $(document).ready(function () {
110112
$('#dumpfMP4').prop('checked', dumpfMP4);
111113
$('#levelCapping').val(levelCapping);
112114

113-
$('h2').append('&nbsp;<a target=_blank href=https://github.com/video-dev/hls.js/releases/tag/v' + Hls.version + '>v' + Hls.version + '</a>');
114-
$('#currentVersion').html('Hls version:' + Hls.version);
115+
// link to version on npm if canary
116+
// github branch for a branch version
117+
// github tag for a normal tag
118+
// github PR for a pr
119+
function getVersionLink (version) {
120+
const alphaRegex = /[-.]0\.alpha\./;
121+
if (alphaRegex.test(version)) {
122+
return `https://www.npmjs.com/package/hls.js/v/${encodeURIComponent(version)}`;
123+
} else if (NETLIFY.reviewID) {
124+
return `https://github.com/video-dev/hls.js/pull/${NETLIFY.reviewID}`;
125+
} else if (NETLIFY.branch) {
126+
return `https://github.com/video-dev/hls.js/tree/${encodeURIComponent(NETLIFY.branch)}`;
127+
}
128+
return `https://github.com/video-dev/hls.js/releases/tag/v${encodeURIComponent(version)}`;
129+
}
130+
131+
const version = Hls.version;
132+
if (version) {
133+
const $a = $('<a />').attr('target', '_blank').attr('href', getVersionLink(version)).text('v' + version);
134+
$('.title').append($a);
135+
}
115136

116137
$('#streamURL').val(sourceURL);
117138

0 commit comments

Comments
 (0)