@internetarchive/radio-player 0.0.3-a4 → 0.0.4-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -661
- package/README.md +142 -142
- package/index.d.ts +15 -15
- package/index.js +28 -28
- package/lib/demo/full-text-search-service.d.ts +14 -14
- package/lib/demo/full-text-search-service.js +33 -33
- package/lib/demo/radio-player-controller.d.ts +41 -41
- package/lib/demo/radio-player-controller.js +199 -199
- package/lib/src/assets/img/left.d.ts +2 -2
- package/lib/src/assets/img/left.js +15 -15
- package/lib/src/assets/img/right.d.ts +2 -2
- package/lib/src/assets/img/right.js +15 -15
- package/lib/src/models/music-zone.d.ts +12 -12
- package/lib/src/models/music-zone.js +15 -15
- package/lib/src/models/radio-player-config.d.ts +26 -26
- package/lib/src/models/radio-player-config.js +27 -27
- package/lib/src/radio-player.d.ts +589 -589
- package/lib/src/radio-player.js +1338 -1338
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-backend.d.ts +82 -82
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-backend.js +107 -107
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-response.d.ts +48 -48
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-response.js +58 -58
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-service-interface.d.ts +16 -16
- package/lib/src/search-handler/search-backends/full-text-search-backend/full-text-search-service-interface.js +1 -1
- package/lib/src/search-handler/search-backends/local-search-backend/local-search-backend.d.ts +27 -27
- package/lib/src/search-handler/search-backends/local-search-backend/local-search-backend.js +42 -42
- package/lib/src/search-handler/search-backends/search-backend-interface.d.ts +9 -9
- package/lib/src/search-handler/search-backends/search-backend-interface.js +1 -1
- package/lib/src/search-handler/search-handler-interface.d.ts +17 -17
- package/lib/src/search-handler/search-handler-interface.js +1 -1
- package/lib/src/search-handler/search-handler.d.ts +83 -83
- package/lib/src/search-handler/search-handler.js +177 -177
- package/lib/src/search-handler/search-helper.d.ts +12 -12
- package/lib/src/search-handler/search-helper.js +22 -22
- package/lib/src/search-handler/search-models.d.ts +45 -45
- package/lib/src/search-handler/search-models.js +49 -49
- package/lib/src/search-handler/transcript-index-interface.d.ts +38 -38
- package/lib/src/search-handler/transcript-index-interface.js +1 -1
- package/lib/src/search-handler/transcript-index.d.ts +53 -53
- package/lib/src/search-handler/transcript-index.js +80 -80
- package/lib/src/search-results-switcher.d.ts +58 -58
- package/lib/src/search-results-switcher.js +133 -133
- package/package.json +93 -93
- package/src/assets/img/left.ts +17 -17
- package/src/assets/img/right.ts +17 -17
- package/src/models/music-zone.ts +17 -17
- package/src/models/radio-player-config.ts +47 -47
- package/src/radio-player.ts +1402 -1402
- package/src/search-handler/search-backends/full-text-search-backend/full-text-search-backend.ts +140 -140
- package/src/search-handler/search-backends/full-text-search-backend/full-text-search-response.ts +110 -110
- package/src/search-handler/search-backends/full-text-search-backend/full-text-search-service-interface.ts +17 -17
- package/src/search-handler/search-backends/local-search-backend/local-search-backend.ts +50 -50
- package/src/search-handler/search-backends/search-backend-interface.ts +10 -10
- package/src/search-handler/search-handler-interface.ts +18 -18
- package/src/search-handler/search-handler.ts +217 -217
- package/src/search-handler/search-helper.ts +25 -25
- package/src/search-handler/search-models.ts +69 -69
- package/src/search-handler/transcript-index-interface.ts +42 -42
- package/src/search-handler/transcript-index.ts +93 -93
- package/src/search-results-switcher.ts +131 -131
|
@@ -1,200 +1,200 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
/* eslint-disable import/no-duplicates */
|
|
17
|
-
import { LitElement, html, } from 'lit';
|
|
18
|
-
import { customElement, property, } from 'lit/decorators.js';
|
|
19
|
-
import { AudioSource } from '@internetarchive/audio-element';
|
|
20
|
-
import { TranscriptConfig, TranscriptEntryConfig } from '@internetarchive/transcript-view';
|
|
21
|
-
import '../src/radio-player';
|
|
22
|
-
import RadioPlayerConfig from '../src/models/radio-player-config';
|
|
23
|
-
import { SearchHandler } from '../src/search-handler/search-handler';
|
|
24
|
-
import { TranscriptIndex } from '../src/search-handler/transcript-index';
|
|
25
|
-
import { FullTextSearchBackend } from '../src/search-handler/search-backends/full-text-search-backend/full-text-search-backend';
|
|
26
|
-
import { FullTextSearchService } from './full-text-search-service';
|
|
27
|
-
// import { LocalSearchBackend } from '../src/search-handler/search-indices/local-search-index';
|
|
28
|
-
let RadioPlayerController = class RadioPlayerController extends LitElement {
|
|
29
|
-
constructor() {
|
|
30
|
-
super(...arguments);
|
|
31
|
-
this.radioPlayerConfig = undefined;
|
|
32
|
-
this.transcriptConfig = undefined;
|
|
33
|
-
this.itemId = 'Euronews_Radio_English_20171029_030000';
|
|
34
|
-
/**
|
|
35
|
-
* The Search Handler
|
|
36
|
-
*
|
|
37
|
-
* @type {(SearchHandlerInterface | undefined)}
|
|
38
|
-
* @memberof RadioPlayer
|
|
39
|
-
*/
|
|
40
|
-
this.searchHandler = undefined;
|
|
41
|
-
this.startPlaybackAt = undefined;
|
|
42
|
-
this.currentTime = 0;
|
|
43
|
-
this.fileName = '';
|
|
44
|
-
this.baseUrl = 'https://archive.org';
|
|
45
|
-
this.searchServicePath = '/services/radio-archive/search/service.php';
|
|
46
|
-
}
|
|
47
|
-
render() {
|
|
48
|
-
return html `
|
|
49
|
-
<radio-player
|
|
50
|
-
.config=${this.radioPlayerConfig}
|
|
51
|
-
.transcriptConfig=${this.transcriptConfig}
|
|
52
|
-
.searchHandler=${this.searchHandler}
|
|
53
|
-
@searchTermChanged=${this.searchTermChanged}
|
|
54
|
-
@playbackPaused=${this.playbackPaused}
|
|
55
|
-
@currentTimeChanged=${this.currentTimeChanged}
|
|
56
|
-
@timeChangedFromScrub=${this.timeChangedFromScrub}
|
|
57
|
-
@transcriptEntrySelected=${this.transcriptEntrySelected}
|
|
58
|
-
@canplay=${this.canplay}
|
|
59
|
-
>
|
|
60
|
-
</radio-player>
|
|
61
|
-
`;
|
|
62
|
-
}
|
|
63
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
64
|
-
loadItemMetadata() {
|
|
65
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const url = `https://archive.org/metadata/${this.itemId}`;
|
|
67
|
-
const response = yield fetch(url);
|
|
68
|
-
const data = yield response.json();
|
|
69
|
-
this.handleMetadataResponse(data);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
fetchTranscript() {
|
|
73
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
-
const srtUrl = `https://archive.org/cors/${this.itemId}/${this.fileName}`;
|
|
75
|
-
const response = yield fetch(srtUrl);
|
|
76
|
-
const json = yield response.json();
|
|
77
|
-
const transcriptEntries = json.map((entry) => new TranscriptEntryConfig(entry.id, entry.start, entry.end, entry.text, entry.is_music, entry.search_match_index));
|
|
78
|
-
this.transcriptConfig = new TranscriptConfig(transcriptEntries);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
setup() {
|
|
82
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
-
yield this.loadItemMetadata();
|
|
84
|
-
yield this.fetchTranscript();
|
|
85
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
86
|
-
const searchTerm = searchParams.get('q');
|
|
87
|
-
const startTime = searchParams.get('start');
|
|
88
|
-
if (searchTerm && this.radioPlayer) {
|
|
89
|
-
this.radioPlayer.searchTerm = searchTerm;
|
|
90
|
-
}
|
|
91
|
-
if (startTime) {
|
|
92
|
-
this.startPlaybackAt = parseFloat(startTime);
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
handleMetadataResponse(response) {
|
|
97
|
-
const metadata = response;
|
|
98
|
-
const collectionIdentifier = metadata.metadata.collection[0];
|
|
99
|
-
const srtFile = metadata.files.find((file) => file.format === 'JSON SRT');
|
|
100
|
-
this.fileName = srtFile.name;
|
|
101
|
-
const originalAudioFile = metadata.files.find((file) => file.source === 'original'
|
|
102
|
-
&& ['vbr mp3', 'ogg vorbis', 'advanced audio coding'].includes(file.format.toLowerCase()));
|
|
103
|
-
const audioFiles = metadata.files.filter((file) => [
|
|
104
|
-
'vbr mp3', 'ogg vorbis'
|
|
105
|
-
].includes(file.format.toLowerCase()));
|
|
106
|
-
const audioSources = audioFiles.map((file) => {
|
|
107
|
-
const url = `https://archive.org/download/${this.itemId}/${file.name}`;
|
|
108
|
-
const mimetype = file.format.toLowerCase() === 'ogg vorbis' ? 'audio/ogg' : 'audio/mpeg';
|
|
109
|
-
return new AudioSource(url, mimetype);
|
|
110
|
-
});
|
|
111
|
-
const waveFormImageFile = metadata.files.find((file) => file.format.toLowerCase() === 'png'
|
|
112
|
-
&& file.original === originalAudioFile.name);
|
|
113
|
-
let waveFormImageUrl;
|
|
114
|
-
if (waveFormImageFile) {
|
|
115
|
-
waveFormImageUrl = `https://archive.org/download/${this.itemId}/${waveFormImageFile.name}`;
|
|
116
|
-
}
|
|
117
|
-
this.radioPlayerConfig = new RadioPlayerConfig(metadata.metadata.contributor, metadata.metadata.start_localtime || metadata.metadata.start_time, `https://archive.org/services/img/${collectionIdentifier}`, waveFormImageUrl, audioSources);
|
|
118
|
-
}
|
|
119
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
120
|
-
get radioPlayer() {
|
|
121
|
-
return this.shadowRoot ? this.shadowRoot.querySelector('radio-player') : null;
|
|
122
|
-
}
|
|
123
|
-
firstUpdated() {
|
|
124
|
-
this.setup();
|
|
125
|
-
}
|
|
126
|
-
updated(changedProperties) {
|
|
127
|
-
if (changedProperties.has('transcriptConfig')) {
|
|
128
|
-
this.setupSearchHandler();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
setupSearchHandler() {
|
|
132
|
-
if (!this.transcriptConfig || !this.itemId) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
const transcriptIndex = new TranscriptIndex(this.transcriptConfig);
|
|
136
|
-
// const searchBackend = new LocalSearchBackend();
|
|
137
|
-
this.searchService = new FullTextSearchService(this.itemId, this.baseUrl, this.searchServicePath);
|
|
138
|
-
const searchBackend = new FullTextSearchBackend(this.searchService);
|
|
139
|
-
this.searchBackend = searchBackend;
|
|
140
|
-
const searchHandler = new SearchHandler(searchBackend, transcriptIndex);
|
|
141
|
-
this.searchHandler = searchHandler;
|
|
142
|
-
}
|
|
143
|
-
canplay() {
|
|
144
|
-
if (this.startPlaybackAt && this.radioPlayer) {
|
|
145
|
-
this.radioPlayer.seekTo(this.startPlaybackAt);
|
|
146
|
-
this.startPlaybackAt = undefined;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
searchTermChanged(e) {
|
|
150
|
-
const { searchTerm } = e.detail;
|
|
151
|
-
this.updateSearchQueryParam(searchTerm);
|
|
152
|
-
}
|
|
153
|
-
currentTimeChanged(e) {
|
|
154
|
-
this.currentTime = e.detail.currentTime;
|
|
155
|
-
}
|
|
156
|
-
playbackPaused() {
|
|
157
|
-
this.updateStartTimeQueryParam();
|
|
158
|
-
}
|
|
159
|
-
timeChangedFromScrub(e) {
|
|
160
|
-
this.currentTime = e.detail.newTime;
|
|
161
|
-
this.updateStartTimeQueryParam();
|
|
162
|
-
}
|
|
163
|
-
transcriptEntrySelected(e) {
|
|
164
|
-
this.currentTime = e.detail.newTime;
|
|
165
|
-
this.updateStartTimeQueryParam();
|
|
166
|
-
}
|
|
167
|
-
updateStartTimeQueryParam() {
|
|
168
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
169
|
-
searchParams.set('start', `${this.currentTime}`);
|
|
170
|
-
window.history.replaceState({}, '', `?${searchParams.toString()}`);
|
|
171
|
-
}
|
|
172
|
-
/* eslint-disable-next-line class-methods-use-this */
|
|
173
|
-
updateSearchQueryParam(searchTerm) {
|
|
174
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
175
|
-
if (searchTerm === '') {
|
|
176
|
-
searchParams.delete('q');
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
searchParams.set('q', `${searchTerm}`);
|
|
180
|
-
}
|
|
181
|
-
window.history.replaceState({}, '', `?${searchParams.toString()}`);
|
|
182
|
-
}
|
|
183
|
-
};
|
|
184
|
-
__decorate([
|
|
185
|
-
property({ type: Object })
|
|
186
|
-
], RadioPlayerController.prototype, "radioPlayerConfig", void 0);
|
|
187
|
-
__decorate([
|
|
188
|
-
property({ type: Object })
|
|
189
|
-
], RadioPlayerController.prototype, "transcriptConfig", void 0);
|
|
190
|
-
__decorate([
|
|
191
|
-
property({ type: String })
|
|
192
|
-
], RadioPlayerController.prototype, "itemId", void 0);
|
|
193
|
-
__decorate([
|
|
194
|
-
property({ type: Object })
|
|
195
|
-
], RadioPlayerController.prototype, "searchHandler", void 0);
|
|
196
|
-
RadioPlayerController = __decorate([
|
|
197
|
-
customElement('radio-player-controller')
|
|
198
|
-
], RadioPlayerController);
|
|
199
|
-
export default RadioPlayerController;
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
/* eslint-disable import/no-duplicates */
|
|
17
|
+
import { LitElement, html, } from 'lit';
|
|
18
|
+
import { customElement, property, } from 'lit/decorators.js';
|
|
19
|
+
import { AudioSource } from '@internetarchive/audio-element';
|
|
20
|
+
import { TranscriptConfig, TranscriptEntryConfig } from '@internetarchive/transcript-view';
|
|
21
|
+
import '../src/radio-player';
|
|
22
|
+
import RadioPlayerConfig from '../src/models/radio-player-config';
|
|
23
|
+
import { SearchHandler } from '../src/search-handler/search-handler';
|
|
24
|
+
import { TranscriptIndex } from '../src/search-handler/transcript-index';
|
|
25
|
+
import { FullTextSearchBackend } from '../src/search-handler/search-backends/full-text-search-backend/full-text-search-backend';
|
|
26
|
+
import { FullTextSearchService } from './full-text-search-service';
|
|
27
|
+
// import { LocalSearchBackend } from '../src/search-handler/search-indices/local-search-index';
|
|
28
|
+
let RadioPlayerController = class RadioPlayerController extends LitElement {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.radioPlayerConfig = undefined;
|
|
32
|
+
this.transcriptConfig = undefined;
|
|
33
|
+
this.itemId = 'Euronews_Radio_English_20171029_030000';
|
|
34
|
+
/**
|
|
35
|
+
* The Search Handler
|
|
36
|
+
*
|
|
37
|
+
* @type {(SearchHandlerInterface | undefined)}
|
|
38
|
+
* @memberof RadioPlayer
|
|
39
|
+
*/
|
|
40
|
+
this.searchHandler = undefined;
|
|
41
|
+
this.startPlaybackAt = undefined;
|
|
42
|
+
this.currentTime = 0;
|
|
43
|
+
this.fileName = '';
|
|
44
|
+
this.baseUrl = 'https://archive.org';
|
|
45
|
+
this.searchServicePath = '/services/radio-archive/search/service.php';
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
return html `
|
|
49
|
+
<radio-player
|
|
50
|
+
.config=${this.radioPlayerConfig}
|
|
51
|
+
.transcriptConfig=${this.transcriptConfig}
|
|
52
|
+
.searchHandler=${this.searchHandler}
|
|
53
|
+
@searchTermChanged=${this.searchTermChanged}
|
|
54
|
+
@playbackPaused=${this.playbackPaused}
|
|
55
|
+
@currentTimeChanged=${this.currentTimeChanged}
|
|
56
|
+
@timeChangedFromScrub=${this.timeChangedFromScrub}
|
|
57
|
+
@transcriptEntrySelected=${this.transcriptEntrySelected}
|
|
58
|
+
@canplay=${this.canplay}
|
|
59
|
+
>
|
|
60
|
+
</radio-player>
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
64
|
+
loadItemMetadata() {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const url = `https://archive.org/metadata/${this.itemId}`;
|
|
67
|
+
const response = yield fetch(url);
|
|
68
|
+
const data = yield response.json();
|
|
69
|
+
this.handleMetadataResponse(data);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
fetchTranscript() {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const srtUrl = `https://archive.org/cors/${this.itemId}/${this.fileName}`;
|
|
75
|
+
const response = yield fetch(srtUrl);
|
|
76
|
+
const json = yield response.json();
|
|
77
|
+
const transcriptEntries = json.map((entry) => new TranscriptEntryConfig(entry.id, entry.start, entry.end, entry.text, entry.is_music, entry.search_match_index));
|
|
78
|
+
this.transcriptConfig = new TranscriptConfig(transcriptEntries);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
setup() {
|
|
82
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
83
|
+
yield this.loadItemMetadata();
|
|
84
|
+
yield this.fetchTranscript();
|
|
85
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
86
|
+
const searchTerm = searchParams.get('q');
|
|
87
|
+
const startTime = searchParams.get('start');
|
|
88
|
+
if (searchTerm && this.radioPlayer) {
|
|
89
|
+
this.radioPlayer.searchTerm = searchTerm;
|
|
90
|
+
}
|
|
91
|
+
if (startTime) {
|
|
92
|
+
this.startPlaybackAt = parseFloat(startTime);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
handleMetadataResponse(response) {
|
|
97
|
+
const metadata = response;
|
|
98
|
+
const collectionIdentifier = metadata.metadata.collection[0];
|
|
99
|
+
const srtFile = metadata.files.find((file) => file.format === 'JSON SRT');
|
|
100
|
+
this.fileName = srtFile.name;
|
|
101
|
+
const originalAudioFile = metadata.files.find((file) => file.source === 'original'
|
|
102
|
+
&& ['vbr mp3', 'ogg vorbis', 'advanced audio coding'].includes(file.format.toLowerCase()));
|
|
103
|
+
const audioFiles = metadata.files.filter((file) => [
|
|
104
|
+
'vbr mp3', 'ogg vorbis'
|
|
105
|
+
].includes(file.format.toLowerCase()));
|
|
106
|
+
const audioSources = audioFiles.map((file) => {
|
|
107
|
+
const url = `https://archive.org/download/${this.itemId}/${file.name}`;
|
|
108
|
+
const mimetype = file.format.toLowerCase() === 'ogg vorbis' ? 'audio/ogg' : 'audio/mpeg';
|
|
109
|
+
return new AudioSource(url, mimetype);
|
|
110
|
+
});
|
|
111
|
+
const waveFormImageFile = metadata.files.find((file) => file.format.toLowerCase() === 'png'
|
|
112
|
+
&& file.original === originalAudioFile.name);
|
|
113
|
+
let waveFormImageUrl;
|
|
114
|
+
if (waveFormImageFile) {
|
|
115
|
+
waveFormImageUrl = `https://archive.org/download/${this.itemId}/${waveFormImageFile.name}`;
|
|
116
|
+
}
|
|
117
|
+
this.radioPlayerConfig = new RadioPlayerConfig(metadata.metadata.contributor, metadata.metadata.start_localtime || metadata.metadata.start_time, `https://archive.org/services/img/${collectionIdentifier}`, waveFormImageUrl, audioSources);
|
|
118
|
+
}
|
|
119
|
+
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
120
|
+
get radioPlayer() {
|
|
121
|
+
return this.shadowRoot ? this.shadowRoot.querySelector('radio-player') : null;
|
|
122
|
+
}
|
|
123
|
+
firstUpdated() {
|
|
124
|
+
this.setup();
|
|
125
|
+
}
|
|
126
|
+
updated(changedProperties) {
|
|
127
|
+
if (changedProperties.has('transcriptConfig')) {
|
|
128
|
+
this.setupSearchHandler();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
setupSearchHandler() {
|
|
132
|
+
if (!this.transcriptConfig || !this.itemId) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const transcriptIndex = new TranscriptIndex(this.transcriptConfig);
|
|
136
|
+
// const searchBackend = new LocalSearchBackend();
|
|
137
|
+
this.searchService = new FullTextSearchService(this.itemId, this.baseUrl, this.searchServicePath);
|
|
138
|
+
const searchBackend = new FullTextSearchBackend(this.searchService);
|
|
139
|
+
this.searchBackend = searchBackend;
|
|
140
|
+
const searchHandler = new SearchHandler(searchBackend, transcriptIndex);
|
|
141
|
+
this.searchHandler = searchHandler;
|
|
142
|
+
}
|
|
143
|
+
canplay() {
|
|
144
|
+
if (this.startPlaybackAt && this.radioPlayer) {
|
|
145
|
+
this.radioPlayer.seekTo(this.startPlaybackAt);
|
|
146
|
+
this.startPlaybackAt = undefined;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
searchTermChanged(e) {
|
|
150
|
+
const { searchTerm } = e.detail;
|
|
151
|
+
this.updateSearchQueryParam(searchTerm);
|
|
152
|
+
}
|
|
153
|
+
currentTimeChanged(e) {
|
|
154
|
+
this.currentTime = e.detail.currentTime;
|
|
155
|
+
}
|
|
156
|
+
playbackPaused() {
|
|
157
|
+
this.updateStartTimeQueryParam();
|
|
158
|
+
}
|
|
159
|
+
timeChangedFromScrub(e) {
|
|
160
|
+
this.currentTime = e.detail.newTime;
|
|
161
|
+
this.updateStartTimeQueryParam();
|
|
162
|
+
}
|
|
163
|
+
transcriptEntrySelected(e) {
|
|
164
|
+
this.currentTime = e.detail.newTime;
|
|
165
|
+
this.updateStartTimeQueryParam();
|
|
166
|
+
}
|
|
167
|
+
updateStartTimeQueryParam() {
|
|
168
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
169
|
+
searchParams.set('start', `${this.currentTime}`);
|
|
170
|
+
window.history.replaceState({}, '', `?${searchParams.toString()}`);
|
|
171
|
+
}
|
|
172
|
+
/* eslint-disable-next-line class-methods-use-this */
|
|
173
|
+
updateSearchQueryParam(searchTerm) {
|
|
174
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
175
|
+
if (searchTerm === '') {
|
|
176
|
+
searchParams.delete('q');
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
searchParams.set('q', `${searchTerm}`);
|
|
180
|
+
}
|
|
181
|
+
window.history.replaceState({}, '', `?${searchParams.toString()}`);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
__decorate([
|
|
185
|
+
property({ type: Object })
|
|
186
|
+
], RadioPlayerController.prototype, "radioPlayerConfig", void 0);
|
|
187
|
+
__decorate([
|
|
188
|
+
property({ type: Object })
|
|
189
|
+
], RadioPlayerController.prototype, "transcriptConfig", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
property({ type: String })
|
|
192
|
+
], RadioPlayerController.prototype, "itemId", void 0);
|
|
193
|
+
__decorate([
|
|
194
|
+
property({ type: Object })
|
|
195
|
+
], RadioPlayerController.prototype, "searchHandler", void 0);
|
|
196
|
+
RadioPlayerController = __decorate([
|
|
197
|
+
customElement('radio-player-controller')
|
|
198
|
+
], RadioPlayerController);
|
|
199
|
+
export default RadioPlayerController;
|
|
200
200
|
//# sourceMappingURL=radio-player-controller.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const image: import("lit-html").TemplateResult<1>;
|
|
2
|
-
export default image;
|
|
1
|
+
declare const image: import("lit-html").TemplateResult<1>;
|
|
2
|
+
export default image;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
const image = html `
|
|
3
|
-
<svg height="13" viewBox="0 0 8 13" width="8" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
-
<path
|
|
5
|
-
d="m-1.5 8.5 5-5 5 5"
|
|
6
|
-
fill="none"
|
|
7
|
-
stroke="#fff"
|
|
8
|
-
stroke-linecap="round"
|
|
9
|
-
stroke-linejoin="round"
|
|
10
|
-
stroke-width="2"
|
|
11
|
-
transform="matrix(0 -1 1 0 -2 9.7)"
|
|
12
|
-
/>
|
|
13
|
-
</svg>
|
|
14
|
-
`;
|
|
15
|
-
export default image;
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
const image = html `
|
|
3
|
+
<svg height="13" viewBox="0 0 8 13" width="8" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<path
|
|
5
|
+
d="m-1.5 8.5 5-5 5 5"
|
|
6
|
+
fill="none"
|
|
7
|
+
stroke="#fff"
|
|
8
|
+
stroke-linecap="round"
|
|
9
|
+
stroke-linejoin="round"
|
|
10
|
+
stroke-width="2"
|
|
11
|
+
transform="matrix(0 -1 1 0 -2 9.7)"
|
|
12
|
+
/>
|
|
13
|
+
</svg>
|
|
14
|
+
`;
|
|
15
|
+
export default image;
|
|
16
16
|
//# sourceMappingURL=left.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const image: import("lit-html").TemplateResult<1>;
|
|
2
|
-
export default image;
|
|
1
|
+
declare const image: import("lit-html").TemplateResult<1>;
|
|
2
|
+
export default image;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
const image = html `
|
|
3
|
-
<svg height="13" viewBox="0 0 8 13" width="8" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
-
<path
|
|
5
|
-
d="m-1.5 8.5 5-5 5 5"
|
|
6
|
-
fill="none"
|
|
7
|
-
stroke="#fff"
|
|
8
|
-
stroke-linecap="round"
|
|
9
|
-
stroke-linejoin="round"
|
|
10
|
-
stroke-width="2"
|
|
11
|
-
transform="matrix(0 -1 -1 0 10 9.7)"
|
|
12
|
-
/>
|
|
13
|
-
</svg>
|
|
14
|
-
`;
|
|
15
|
-
export default image;
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
const image = html `
|
|
3
|
+
<svg height="13" viewBox="0 0 8 13" width="8" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
<path
|
|
5
|
+
d="m-1.5 8.5 5-5 5 5"
|
|
6
|
+
fill="none"
|
|
7
|
+
stroke="#fff"
|
|
8
|
+
stroke-linecap="round"
|
|
9
|
+
stroke-linejoin="round"
|
|
10
|
+
stroke-width="2"
|
|
11
|
+
transform="matrix(0 -1 -1 0 10 9.7)"
|
|
12
|
+
/>
|
|
13
|
+
</svg>
|
|
14
|
+
`;
|
|
15
|
+
export default image;
|
|
16
16
|
//# sourceMappingURL=right.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A data model for defining a zone of music, which is used
|
|
3
|
-
* to skip over the zone if it is enabled.
|
|
4
|
-
*
|
|
5
|
-
* @export
|
|
6
|
-
* @class MusicZone
|
|
7
|
-
*/
|
|
8
|
-
export default class MusicZone {
|
|
9
|
-
start: number;
|
|
10
|
-
end: number;
|
|
11
|
-
constructor(start: number, end: number);
|
|
12
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* A data model for defining a zone of music, which is used
|
|
3
|
+
* to skip over the zone if it is enabled.
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @class MusicZone
|
|
7
|
+
*/
|
|
8
|
+
export default class MusicZone {
|
|
9
|
+
start: number;
|
|
10
|
+
end: number;
|
|
11
|
+
constructor(start: number, end: number);
|
|
12
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A data model for defining a zone of music, which is used
|
|
3
|
-
* to skip over the zone if it is enabled.
|
|
4
|
-
*
|
|
5
|
-
* @export
|
|
6
|
-
* @class MusicZone
|
|
7
|
-
*/
|
|
8
|
-
export default class MusicZone {
|
|
9
|
-
constructor(start, end) {
|
|
10
|
-
this.start = 0;
|
|
11
|
-
this.end = 0;
|
|
12
|
-
this.start = start;
|
|
13
|
-
this.end = end;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* A data model for defining a zone of music, which is used
|
|
3
|
+
* to skip over the zone if it is enabled.
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @class MusicZone
|
|
7
|
+
*/
|
|
8
|
+
export default class MusicZone {
|
|
9
|
+
constructor(start, end) {
|
|
10
|
+
this.start = 0;
|
|
11
|
+
this.end = 0;
|
|
12
|
+
this.start = start;
|
|
13
|
+
this.end = end;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
16
|
//# sourceMappingURL=music-zone.js.map
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { AudioSource } from '@internetarchive/audio-element';
|
|
2
|
-
/**
|
|
3
|
-
* A data model to configure the Radio Player.
|
|
4
|
-
*
|
|
5
|
-
* @export
|
|
6
|
-
* @class RadioPlayerConfig
|
|
7
|
-
*/
|
|
8
|
-
export default class RadioPlayerConfig {
|
|
9
|
-
title: string;
|
|
10
|
-
date: string;
|
|
11
|
-
logoUrl: string;
|
|
12
|
-
waveformUrl: string | undefined;
|
|
13
|
-
audioSources: AudioSource[];
|
|
14
|
-
quickSearches: string[];
|
|
15
|
-
/**
|
|
16
|
-
* Creates an instance of RadioPlayerConfig.
|
|
17
|
-
* @param {string} title
|
|
18
|
-
* @param {string} date
|
|
19
|
-
* @param {string} logoUrl
|
|
20
|
-
* @param {string} waveformUrl
|
|
21
|
-
* @param {AudioSource[]} audioSources
|
|
22
|
-
* @param {string[]} [quickSearches=[]]
|
|
23
|
-
* @memberof RadioPlayerConfig
|
|
24
|
-
*/
|
|
25
|
-
constructor(title: string, date: string, logoUrl: string, waveformUrl: string | undefined, audioSources: AudioSource[], quickSearches?: string[]);
|
|
26
|
-
}
|
|
1
|
+
import { AudioSource } from '@internetarchive/audio-element';
|
|
2
|
+
/**
|
|
3
|
+
* A data model to configure the Radio Player.
|
|
4
|
+
*
|
|
5
|
+
* @export
|
|
6
|
+
* @class RadioPlayerConfig
|
|
7
|
+
*/
|
|
8
|
+
export default class RadioPlayerConfig {
|
|
9
|
+
title: string;
|
|
10
|
+
date: string;
|
|
11
|
+
logoUrl: string;
|
|
12
|
+
waveformUrl: string | undefined;
|
|
13
|
+
audioSources: AudioSource[];
|
|
14
|
+
quickSearches: string[];
|
|
15
|
+
/**
|
|
16
|
+
* Creates an instance of RadioPlayerConfig.
|
|
17
|
+
* @param {string} title
|
|
18
|
+
* @param {string} date
|
|
19
|
+
* @param {string} logoUrl
|
|
20
|
+
* @param {string} waveformUrl
|
|
21
|
+
* @param {AudioSource[]} audioSources
|
|
22
|
+
* @param {string[]} [quickSearches=[]]
|
|
23
|
+
* @memberof RadioPlayerConfig
|
|
24
|
+
*/
|
|
25
|
+
constructor(title: string, date: string, logoUrl: string, waveformUrl: string | undefined, audioSources: AudioSource[], quickSearches?: string[]);
|
|
26
|
+
}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A data model to configure the Radio Player.
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @class RadioPlayerConfig
|
|
6
|
-
*/
|
|
7
|
-
export default class RadioPlayerConfig {
|
|
8
|
-
/**
|
|
9
|
-
* Creates an instance of RadioPlayerConfig.
|
|
10
|
-
* @param {string} title
|
|
11
|
-
* @param {string} date
|
|
12
|
-
* @param {string} logoUrl
|
|
13
|
-
* @param {string} waveformUrl
|
|
14
|
-
* @param {AudioSource[]} audioSources
|
|
15
|
-
* @param {string[]} [quickSearches=[]]
|
|
16
|
-
* @memberof RadioPlayerConfig
|
|
17
|
-
*/
|
|
18
|
-
constructor(title, date, logoUrl, waveformUrl, audioSources, quickSearches = []) {
|
|
19
|
-
this.quickSearches = [];
|
|
20
|
-
this.title = title;
|
|
21
|
-
this.date = date;
|
|
22
|
-
this.logoUrl = logoUrl;
|
|
23
|
-
this.waveformUrl = waveformUrl;
|
|
24
|
-
this.audioSources = audioSources;
|
|
25
|
-
this.quickSearches = quickSearches;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* A data model to configure the Radio Player.
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @class RadioPlayerConfig
|
|
6
|
+
*/
|
|
7
|
+
export default class RadioPlayerConfig {
|
|
8
|
+
/**
|
|
9
|
+
* Creates an instance of RadioPlayerConfig.
|
|
10
|
+
* @param {string} title
|
|
11
|
+
* @param {string} date
|
|
12
|
+
* @param {string} logoUrl
|
|
13
|
+
* @param {string} waveformUrl
|
|
14
|
+
* @param {AudioSource[]} audioSources
|
|
15
|
+
* @param {string[]} [quickSearches=[]]
|
|
16
|
+
* @memberof RadioPlayerConfig
|
|
17
|
+
*/
|
|
18
|
+
constructor(title, date, logoUrl, waveformUrl, audioSources, quickSearches = []) {
|
|
19
|
+
this.quickSearches = [];
|
|
20
|
+
this.title = title;
|
|
21
|
+
this.date = date;
|
|
22
|
+
this.logoUrl = logoUrl;
|
|
23
|
+
this.waveformUrl = waveformUrl;
|
|
24
|
+
this.audioSources = audioSources;
|
|
25
|
+
this.quickSearches = quickSearches;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
28
|
//# sourceMappingURL=radio-player-config.js.map
|