-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: add ttplayervideo support dynamic use mse, and create stand…
…ard mse library add ttplayervideo support dynamic use mse, and create standard mse library, delete useless video component and control component relative dependency, update relative rollup script code
- Loading branch information
1 parent
6e40a31
commit cd3ec19
Showing
29 changed files
with
365 additions
and
554 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import TTPlayerVideo from '.'; | ||
|
||
interface IMSECtor { | ||
new (video: TTPlayerVideo): MSE; | ||
} | ||
|
||
class MSE { | ||
|
||
public video: TTPlayerVideo; | ||
constructor (video: TTPlayerVideo) { | ||
this.video = video; | ||
} | ||
|
||
checkType (url: string, type: string): boolean { | ||
console.log(url, type); | ||
return false; | ||
} | ||
|
||
initMSE (url: string, options?: any) { | ||
console.log(url, options); | ||
} | ||
|
||
clearMSE () {} | ||
|
||
} | ||
|
||
export { IMSECtor }; | ||
|
||
export default MSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# `mse` | ||
|
||
> TODO: description | ||
## Usage | ||
|
||
``` | ||
const mse = require('mse'); | ||
// TODO: DEMONSTRATE API | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
{ | ||
"name": "@dking/ttplayer-video", | ||
"name": "@dking/ttplayer-mse", | ||
"version": "0.0.3", | ||
"description": "ccplayer-video", | ||
"description": "> TODO: description", | ||
"author": "cjw <[email protected]>", | ||
"homepage": "https://github.com/JohnApache/TT-Player#readme", | ||
"license": "MIT", | ||
"main": "./lib/index.js", | ||
"module": "./lib/index.esm.js", | ||
"typings": "./lib/index.d.ts", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"directories": { | ||
"lib": "lib", | ||
"test": "__tests__" | ||
|
@@ -22,13 +19,13 @@ | |
"type": "git", | ||
"url": "git+https://github.com/JohnApache/TT-Player.git" | ||
}, | ||
"scripts": {}, | ||
"scripts": { | ||
"test": "echo \"Error: run tests from root\" && exit 1" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/JohnApache/TT-Player/issues" | ||
}, | ||
"dependencies": { | ||
"@dking/ttplayer-core": "^0.0.3", | ||
"@dking/ttplayer-utils": "^0.0.3", | ||
"eventemitter3": "^4.0.0" | ||
"@dking/ttplayer-core": "^0.0.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { MediaPlayerClass } from './dash'; | ||
import { VideoMSE, TTPlayerVideo } from '@dking/ttplayer-core'; | ||
|
||
declare global { | ||
interface Window { | ||
dashjs: MediaPlayerClass; | ||
} | ||
} | ||
|
||
class DashMSE extends VideoMSE { | ||
|
||
static MSE_TYPE: string = 'dash'; | ||
public MSE_TYPE: string; | ||
public __dash__: MediaPlayerClass | null = null; | ||
|
||
constructor (video: TTPlayerVideo) { | ||
super(video); | ||
this.handleMSEError = this.handleMSEError.bind(this); | ||
/* eslint-disable */ | ||
this.MSE_TYPE = (this.constructor as typeof DashMSE).MSE_TYPE || 'auto'; | ||
/* eslint-enable */ | ||
} | ||
|
||
checkType (url: string, type: string = 'auto'): boolean { | ||
if (type === this.MSE_TYPE) return true; | ||
return type === 'auto' && !!(/.mpd(#|\?|$)/i).exec(url); | ||
} | ||
|
||
initMSE (url: string, dashOption?: any) { | ||
const dashjs = window.dashjs; | ||
if (!dashjs) throw new Error(`can't find dashjs`); | ||
const dash = dashjs.MediaPlayer().create(); | ||
dashOption && dash.updateSettings(dashOption); | ||
dash.initialize(this.video.mediaDom, url, false); | ||
dash.on('error', this.handleMSEError); | ||
this.__dash__ = dash; | ||
} | ||
|
||
clearMSE () { | ||
if (this.__dash__) { | ||
this.__dash__.off('error', this.handleMSEError); | ||
this.__dash__.reset(); | ||
} | ||
this.__dash__ = null; | ||
} | ||
|
||
private handleMSEError (error: any) { | ||
this.video.event.emit('error', error); | ||
} | ||
|
||
} | ||
|
||
export default DashMSE; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import FlvJs from './flv'; | ||
import { VideoMSE, TTPlayerVideo } from '@dking/ttplayer-core'; | ||
|
||
declare global { | ||
interface Window { | ||
flvjs: typeof FlvJs; | ||
} | ||
} | ||
|
||
class FlvMSE extends VideoMSE { | ||
|
||
static MSE_TYPE: string = 'flv'; | ||
public MSE_TYPE: string; | ||
public __flv__: FlvJs.Player | null = null; | ||
constructor (video: TTPlayerVideo) { | ||
super(video); | ||
this.handleFlvError = this.handleFlvError.bind(this); | ||
/* eslint-disable */ | ||
this.MSE_TYPE = (this.constructor as typeof FlvMSE).MSE_TYPE || 'auto'; | ||
/* eslint-enable */ | ||
} | ||
|
||
checkType (url: string, type: string = 'auto'): boolean { | ||
if (type === this.MSE_TYPE) return true; | ||
return type === 'auto' && !!(/.flv(#|\?|$)/i).exec(url); | ||
} | ||
|
||
initMSE (url: string, flvjsOption?: any) { | ||
const { | ||
mediaDataSource = {}, | ||
config = {}, | ||
} = flvjsOption || {}; | ||
const flvjs = window.flvjs; | ||
if (!flvjs) throw new Error(`can't find flvjs`); | ||
if (!flvjs.isSupported()) throw new Error(`flv is not supported`); | ||
|
||
const options = { | ||
url : url, | ||
type: 'flv', | ||
...mediaDataSource, | ||
}; | ||
|
||
const flv = flvjs.createPlayer(options, config); | ||
flv.attachMediaElement(this.video.mediaDom); | ||
flv.load(); | ||
flv.on('error', this.handleFlvError); | ||
this.__flv__ = flv; | ||
} | ||
|
||
clearMSE () { | ||
if (this.__flv__) { | ||
this.__flv__.off('error', this.handleFlvError); | ||
this.__flv__.destroy(); | ||
} | ||
this.__flv__ = null; | ||
} | ||
|
||
private handleFlvError (error: any) { | ||
this.video.event.emit('error', error); | ||
} | ||
|
||
} | ||
|
||
export default FlvMSE; |
File renamed without changes.
Oops, something went wrong.