Skip to content

Commit

Permalink
see changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed Mar 13, 2024
1 parent a2f1874 commit 72f030e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 33 deletions.
45 changes: 25 additions & 20 deletions examples/standalone/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,6 @@ const player = Player.make<Ctx>('#player', {
new PlaylistPlugin({
initialIndex,
sources: [
{
title: 'webtorrent - MP4 + subtitle + poster',
src: 'https://webtorrent.io/torrents/sintel.torrent',
// 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent',
poster: 'https://api.imlazy.ink/img?webtorrent'
},
{
title: 'HLS with default SRT subtitle',
src: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
poster: 'https://api.imlazy.ink/img?id19',
subtitles: [
{
name: 'Default',
default: true,
src: SRT,
offset: 2
}
],
duration: '10:34'
},
{
title: '君の名は - MP4',
poster: POSTER,
Expand All @@ -145,6 +125,25 @@ const player = Player.make<Ctx>('#player', {
],
highlights: highlight
},
{
title: 'HLS with default SRT subtitle',
src: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
poster: 'https://api.imlazy.ink/img?id19',
subtitles: [
{
name: 'Default',
default: true,
src: SRT,
offset: 2
}
],
duration: '10:34'
},
{
title: 'BROKEN SOURCE',
src: '//',
duration: '00:00'
},
{
title: 'Big Buck Bunny - HLS',
src: 'https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8',
Expand All @@ -159,6 +158,12 @@ const player = Player.make<Ctx>('#player', {
title: 'FLV',
src: FLV,
duration: '00:17'
},
{
title: 'webtorrent - MP4 + subtitle + poster',
src: 'https://webtorrent.io/torrents/sintel.torrent',
// 'magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F&xs=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2Fsintel.torrent',
poster: 'https://api.imlazy.ink/img?webtorrent'
}
]
// m3uList: {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oplayer/core",
"version": "1.2.33-beta.1",
"version": "1.2.33-beta.2",
"description": "Oh! Another HTML5 video player.",
"type": "module",
"main": "./dist/index.es.js",
Expand Down
13 changes: 8 additions & 5 deletions packages/core/src/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,14 @@ export class Player<Context extends Record<string, any> = Record<string, any>> {
if (!this.$root) return
this.off(canplay, canplayHandler)
this.emit(options.brokenEvent, finalSource || sourceLike)
if (options.event == 'videoqualitychanged') {
this.load(this.options.source).then(() => {
rollback()
this.isSourceChanging = false
})
if (options.event == 'videosourcechanged') {
this.isSourceChanging = false
} else {
this.load(this.options.source)
.then(rollback)
.finally(() => {
this.isSourceChanging = false
})
}
reject(e)
}
Expand Down
10 changes: 5 additions & 5 deletions packages/plugins/src/playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,20 @@ export default class PlaylistPlugin implements PlayerPlugin {
})
})
.then(() => {
this.currentIndex = idx
this.player.emit('playlistsourcechange', { source, id: idx })
this.$root.querySelector('.playlist-list-item.active')?.classList.remove('active')
$target?.classList.add('active')
if (this.options.autoHide) {
setTimeout(() => {
this.hideUI()
}, 500)
}
})
.catch((err) => {
this.player.emit('playlistsourceerror', err)
.catch((error) => {
this.player.emit('playlistsourceerror', { error, idx })
})
.finally(() => {
this.currentIndex = idx
this.$root.querySelector('.playlist-list-item.active')?.classList.remove('active')
$target?.classList.add('active')
setTimeout(() => {
this.$root.classList.remove('wait')
$target?.classList.remove('progress')
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oplayer/ui",
"version": "1.2.36-beta.0",
"version": "1.2.36-beta.1",
"description": "ui plugin for oplayer",
"type": "module",
"main": "./dist/index.es.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/src/components/Error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const render = (player: Player, el: HTMLElement, config: UiConfig) => {
}
}

player.on(['videosourcechange', 'videoqualitychange'], clear)
player.on(['videosourcechange', 'videoqualitychange', 'loadedmetadata'], clear)
player.on('error', ({ payload }) => cx(payload))

return show
Expand Down

0 comments on commit 72f030e

Please sign in to comment.