Skip to content

Commit

Permalink
bump full version
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiya authored Aug 27, 2024
1 parent d0953b5 commit 78debfb
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 25 deletions.
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": false,
"trailingComma": "none",
"singleQuote": true,
"printWidth": 110,
"tabWidth": 2
}
7 changes: 0 additions & 7 deletions .prettierrc.js

This file was deleted.

71 changes: 62 additions & 9 deletions packages/docs/src/pages/docs/guide/start.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,100 @@ import { Callout, Tab, Tabs } from 'nextra-theme-docs'

<Tab>
```shell
npm i @oplayer/core @oplayer/ui
npm i @oplayer/core @oplayer/ui @oplayer/hls
```

```js filename="app.js"
import Player from '@oplayer/core'
import ui from '@oplayer/ui'
import OUI from '@oplayer/ui'
import OHls from '@oplayer/hls'

Player.make('#oplayer', {
source: {
title: '君の名は',
src: 'https://cdn.jsdelivr.net/gh/shiyiya/QI-ABSL@master/o/君の名は.mp4',
poster: 'https://cdn.jsdelivr.net/gh/shiyiya/QI-ABSL@master/o/poster.png'
}
})
.use([ui()])
.use([
OUI({
subtitle: {
source: [
{
name: 'Japanese',
default: true,
src: 'https://cdn.jsdelivr.net/gh/shiyiya/QI-ABSL@master/o/君の名は-jp.srt',
offset: 2
},
{
name: 'CH & JP',
src: 'https://cdn.jsdelivr.net/gh/shiyiya/QI-ABSL@master/o/君の名は.srt',
offset: 2
}
]
},
thumbnails: {
src: 'https://cdn.jsdelivr.net/gh/shiyiya/QI-ABSL@master/o/thumbnails.jpg',
number: 100
}
}),
OHls({ forceHLS: true })
])
.create()
```

</Tab>

<Tab>
```html filename="app.html"
<!-- Includes ui -->
<script src="https://cdn.jsdelivr.net/npm/@oplayer/core@latest/dist/index.ui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@oplayer/hls@latest/dist/index.min.js"></script>

<script>
OPlayer.make('#oplayer', {
source: {
title: '君の名は',
src: 'https://cdn.jsdelivr.net/gh/shiyiya/QI-ABSL@master/o/君の名は.mp4',
poster: 'https://cdn.jsdelivr.net/gh/shiyiya/QI-ABSL@master/o/poster.png'
}
})
.use([OUI()])
.use([
OUI({
subtitle: {
source: [
{
name: 'Japanese',
default: true,
src: 'https://cdn.jsdelivr.net/gh/shiyiya/QI-ABSL@master/o/君の名は-jp.srt',
offset: 2
},
{
name: 'CH & JP',
src: 'https://cdn.jsdelivr.net/gh/shiyiya/QI-ABSL@master/o/君の名は.srt',
offset: 2
}
]
},
thumbnails: {
src: 'https://cdn.jsdelivr.net/gh/shiyiya/QI-ABSL@master/o/thumbnails.jpg',
number: 100
}
}),
OHls({
forceHLS: true,
// will lazy load hls.js
library: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/hls.min.js'
})
])
.create()
</script>

```
</Tab>

<Tab>
```html filename="app.html"
<!-- Includes ui & hls & dash & mpegts -->
<!-- Lazy load hls.js dashjs ... -->
<!-- all in one (~28kB) -->
<script src="https://cdn.jsdelivr.net/npm/@oplayer/full@latest/dist/index.min.js"></script>
<script>
OPlayer.make('#oplayer', {
Expand All @@ -58,8 +112,6 @@ Player.make('#oplayer', {
OUI(),
OHls({
forceHLS: true,
// lazy load
library: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/hls.min.js'
}),
ODash({ library: 'https://cdn.dashjs.org/latest/dash.all.min.js' }),
Expand All @@ -69,6 +121,7 @@ Player.make('#oplayer', {
</script>
```

</Tab>

</Tabs>
2 changes: 1 addition & 1 deletion packages/full/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oplayer/full",
"version": "0.0.1-beta.0",
"version": "0.0.1-beta.1",
"description": "all loader in one",
"type": "module",
"main": "./dist/index.min.js",
Expand Down
18 changes: 10 additions & 8 deletions packages/hls/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const generateSetting = (player: Player, instance: Hls, options: HlsPlugin['opti
const ui = player.context.ui
if (options.qualityControl) {
instance.once(HlsPlugin.library.Events.LEVEL_LOADED, () => {
if (instance.levels.length < 1) return
if (instance.levels.length < 2) return
const defaultLevel = options.defaultQuality(instance.levels)
if (defaultLevel != -1) instance.currentLevel = defaultLevel

Expand Down Expand Up @@ -256,7 +256,7 @@ const generateSetting = (player: Player, instance: Hls, options: HlsPlugin['opti

if (options.audioControl) {
instance.once(HlsPlugin.library.Events.LEVEL_LOADED, () => {
if (instance.audioTracks.length < 1) return
if (instance.audioTracks.length < 2) return

let defaultAudio: number | undefined = options.defaultAudio(instance.audioTracks)
if (defaultAudio == -1) {
Expand All @@ -265,7 +265,9 @@ const generateSetting = (player: Player, instance: Hls, options: HlsPlugin['opti
})?.id
}

if (defaultAudio != -1 && defaultAudio != undefined) instance.audioTrack = defaultAudio
if (defaultAudio != -1 && defaultAudio != undefined) {
instance.audioTrack = defaultAudio
}

injectSetting({
icon: ui.icons.lang,
Expand All @@ -286,7 +288,7 @@ const generateSetting = (player: Player, instance: Hls, options: HlsPlugin['opti

if (options.textControl)
instance.once(HlsPlugin.library.Events.SUBTITLE_TRACK_LOADED, () => {
if (instance.subtitleTracks.length < 1) return
if (instance.subtitleTracks.length < 2) return

let defaultSubtitle: number | undefined = options.defaultSubtitle(instance.subtitleTracks)
if (defaultSubtitle == -1) {
Expand All @@ -295,7 +297,9 @@ const generateSetting = (player: Player, instance: Hls, options: HlsPlugin['opti
})?.id
}

if (defaultSubtitle != -1 && defaultSubtitle != undefined) instance.subtitleTrack = defaultSubtitle
if (defaultSubtitle != -1 && defaultSubtitle != undefined) {
instance.subtitleTrack = defaultSubtitle
}

injectSetting({
icon: ui.icons.subtitle,
Expand Down Expand Up @@ -324,12 +328,10 @@ const generateSetting = (player: Player, instance: Hls, options: HlsPlugin['opti
function injectSetting(arg: {
icon: string
name: string
settings: () => { name: string; default: boolean; value: any }[] | void
settings: () => { name: string; default: boolean; value: any }[]
onChange: (it: { value: any }) => void
}) {
const settings = arg.settings()
if (settings && settings.length < 2) return

const { name, icon, onChange } = arg

player.context.ui.setting.unregister(`${PLUGIN_NAME}-${name}`)
Expand Down

0 comments on commit 78debfb

Please sign in to comment.