Skip to content

Commit

Permalink
fix plugin bundle exports
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya committed May 12, 2024
1 parent 46b3a51 commit b9af71e
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 202 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OPlayer

⚡ Oh! Another HTML5 video player.
⚡ Oh! Another HTML5 video player. Do More, Keep it simple.

[📕 Documentation](https://oplayer.vercel.app) | [🧡 Donate](#support) | [💜 Contributing](./CONTRIBUTING.md) | [🎈 Demo](https://oplayer.vercel.app/oplayer.html?playlist=%5B%7B"title"%3A"Disney%27s+Oceans+-+MP4"%2C"src"%3A"https%3A%2F%2Fvjs.zencdn.net%2Fv%2Foceans.mp4"%2C"poster"%3A"https%3A%2F%2Fvjs.zencdn.net%2Fv%2Foceans.png"%2C"duration"%3A"00%3A46"%7D%2C%7B"title"%3A"Big+Buck+Bunny+-+HLS"%2C"src"%3A"https%3A%2F%2Ftest-streams.mux.dev%2Fx36xhzz%2Fx36xhzz.m3u8"%2C"poster"%3A"https%3A%2F%2Fd2zihajmogu5jn.cloudfront.net%2Fbig-buck-bunny%2Fbbb.png"%2C"duration"%3A"10%3A34"%7D%2C%7B"title"%3A"Big+Buck+Bunny+-+DASH"%2C"src"%3A"https%3A%2F%2Fdash.akamaized.net%2Fakamai%2Fbbb_30fps%2Fbbb_30fps.mpd"%2C"poster"%3A"https%3A%2F%2Fd2zihajmogu5jn.cloudfront.net%2Fbig-buck-bunny%2Fbbb.png"%2C"duration"%3A"10%3A34"%7D%5D&p=0)

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@babel/plugin-transform-template-literals": "^7.24.1",
"@changesets/cli": "^2.27.1",
"@rollup/plugin-babel": "^6.0.4",
"@types/node": "^20.12.8",
"@types/node": "^20.12.11",
"@vitejs/plugin-react": "^4.2.1",
"babel-plugin-syntax-trailing-function-commas": "^6.22.0",
"concurrently": "^8.2.2",
Expand All @@ -53,7 +53,7 @@
"lint-staged": "^15.2.2",
"nx": "^18.3.4",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"rimraf": "^5.0.7",
"terser": "^5.31.0",
"tslib": "^2.6.2",
"typescript": "^5.4.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"react-dom": "^18.3.1"
},
"devDependencies": {
"@types/react": "^18.3.1",
"@types/react": "^18.3.2",
"@types/react-dom": "^18.3.0",
"sass": "^1.76.0"
"sass": "^1.77.1"
}
}
73 changes: 33 additions & 40 deletions packages/docs/public/oplayer.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,16 @@
<body>
<div id="oplayer"></div>

<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/core@latest/dist/index.ui.js"></script>

<script src="https://cdn.jsdelivr.net/npm/@oplayer/hls@1.2.26-beta.4/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/dash@1.2.25/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/mpegts@1.2.24/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/hls@latest/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/dash@latest/dist/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/mpegts@latest/dist/index.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/@oplayer/plugins@1.0.12/dist/airplay.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/chromecast.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/plugins@latest/dist/index.min.js"></script>
<!-- <script src="../../plugins/dist/index.min.js"></script> -->

<script>
var playlistScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/[email protected]/dist/playlist.min.js'
var danmakuScriptCdn = 'https://cdn.jsdelivr.net/npm/@oplayer/danmaku@latest/dist/index.min.js'

var query = document.location.search.substring(1)
Expand Down Expand Up @@ -262,7 +260,7 @@
volume: localStorage.getItem('@oplayer/UserPreferences/volume') || 1
})
.use([
OUI({
OPlayer.ui({
theme: {
watermark,
controller: {
Expand Down Expand Up @@ -314,8 +312,8 @@
}),
ODash({ library: 'https://cdn.dashjs.org/latest/dash.all.min.js' }),
OMpegts({ library: 'https://cdn.jsdelivr.net/npm/mpegts.js/dist/mpegts.min.js' }),
new OAirplay(),
new OChromecast()
new OPlugin.AirPlay(),
new OPlugin.Chromecast()
])
.create()
.on((e) => {
Expand All @@ -325,37 +323,32 @@
})

if (playlist.length) {
deps.push([
playlistScriptCdn,
() => {
player.applyPlugin(
new OPlaylist({
initialIndex: p,
autoHide: false,
sources: playlist,
m3uList: m3u
? {
sourceFormat(info) {
try {
const chunk = info.title.substring(3).split('" ')
const titleWith = /group-title="(.+",.+)/.exec(info.title)
const posterWith = /tvg-logo="(.+)"/.exec(info.title)
return {
src: info.uri,
format: 'm3u8',
title: titleWith ? titleWith[1] : /group-title="(.+)"/.exec(info.title)[1],
poster: posterWith && posterWith[1]
}
} catch (error) {
return { src: info.uri, title: info.title, format: 'm3u8' }
}
player.applyPlugin(
new OPlugin.Playlist({
initialIndex: p,
autoHide: false,
sources: playlist,
m3uList: m3u
? {
sourceFormat(info) {
try {
const chunk = info.title.substring(3).split('" ')
const titleWith = /group-title="(.+",.+)/.exec(info.title)
const posterWith = /tvg-logo="(.+)"/.exec(info.title)
return {
src: info.uri,
format: 'm3u8',
title: titleWith ? titleWith[1] : /group-title="(.+)"/.exec(info.title)[1],
poster: posterWith && posterWith[1]
}
} catch (error) {
return { src: info.uri, title: info.title, format: 'm3u8' }
}
: false
})
)
}
])
}
}
: false
})
)
}

if (danmaku || playlist.some((it) => it.danmaku)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/build-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function buildPlugin(name, dev) {
lib: {
entry: plugins[name],
formats: dev ? ['es'] : ['es', 'umd'],
name: dev ? undefined : 'O' + outfileName.charAt(0).toUpperCase() + outfileName.slice(1),
name: name == 'index' ? 'OPlugin' : 'O' + outfileName.charAt(0).toUpperCase() + outfileName.slice(1),
fileName: (format) => `${outfileName}.${{ es: 'es', umd: 'min' }[format]}.js`
},
rollupOptions: { external, output: { dir: 'dist', globals } }
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ import vttThumbnails from './src/vttThumbnails'
import PlaylistPlugin from './src/playlist'
import ad from './src/ad'

export { Chromecast, AirPlay, vttThumbnails, ad, PlaylistPlugin }
export { Chromecast, AirPlay, vttThumbnails, ad, PlaylistPlugin as Playlist }
2 changes: 1 addition & 1 deletion packages/plugins/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@oplayer/ui": "workspace:*",
"@types/chromecast-caf-sender": "^1.0.9",
"chokidar": "^3.6.0",
"glob": "^10.3.12",
"glob": "^10.3.15",
"m3u8-parser": "^7.1.0",
"vite-plugin-css-injected-by-js": "^3.5.1"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
},
"devDependencies": {
"@oplayer/core": "workspace:*",
"@types/react": "^18.3.1",
"@types/react": "^18.3.2",
"react": "^18.3.1",
"react-dom": "^18.3.1"
}
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.3.2-beta.0",
"version": "1.3.2-beta.1",
"description": "ui plugin for oplayer",
"type": "module",
"main": "./dist/index.es.js",
Expand Down
24 changes: 7 additions & 17 deletions packages/ui/src/components/Subtitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,9 @@ export class Subtitle {
}

this.options = { source: [], ...options }
this.processDefault(this.options.source)

this.createContainer()
this.loadSetting()

if (this.currentSubtitle) {
if (this.player.isSourceChanging || isNaN(this.player.duration) || this.player.duration < 1) {
this.player.once('loadedmetadata', () => this.fetchSubtitle())
} else {
this.fetchSubtitle()
}
}
this.changeSource(this.options.source)

this.player.on(['destroy', 'videosourcechange'], this.destroy.bind(this))
this.player.on('videoqualitychang', () => {
Expand All @@ -68,15 +59,14 @@ export class Subtitle {
changeSource(payload: SubtitleSource[]) {
this.setting?.unregister(SETTING_KEY)
this.processDefault(payload)
const next = () => {
this.loadSetting()
this.player.emit('subtitlesourcechange', payload)
this.fetchSubtitle()
}
this.loadSetting()

if (!this.currentSubtitle) return

if (this.player.isSourceChanging || isNaN(this.player.duration) || this.player.duration < 1) {
this.player.once('loadedmetadata', next)
this.player.once('loadedmetadata', this.fetchSubtitle.bind(this))
} else {
next()
this.fetchSubtitle()
}
}

Expand Down
Loading

0 comments on commit b9af71e

Please sign in to comment.