Skip to content

Commit

Permalink
Merge pull request #1193 from canalplus/misc/stream-no-rxjs
Browse files Browse the repository at this point in the history
Completely remove RxJS dependency from the RxPlayer's source code.
  • Loading branch information
peaBerberian committed Jan 31, 2023
2 parents cd9c7c0 + 53b2ab6 commit 8e14c94
Show file tree
Hide file tree
Showing 117 changed files with 4,530 additions and 6,636 deletions.
12 changes: 8 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@
"url": "git://github.com/canalplus/rx-player.git"
},
"dependencies": {
"next-tick": "1.1.0",
"rxjs": "7.5.7"
"next-tick": "1.1.0"
},
"devDependencies": {
"@babel/core": "7.20.2",
Expand Down Expand Up @@ -122,6 +121,7 @@
"react-dom": "18.2.0",
"regenerator-runtime": "0.13.10",
"rimraf": "3.0.2",
"rxjs": "7.5.7",
"semver": "7.3.8",
"sinon": "14.0.2",
"terser-webpack-plugin": "5.3.6",
Expand Down
73 changes: 0 additions & 73 deletions src/compat/__tests__/play.test.ts

This file was deleted.

71 changes: 0 additions & 71 deletions src/compat/__tests__/set_element_src.test.ts

This file was deleted.

109 changes: 0 additions & 109 deletions src/compat/__tests__/when_loaded_metadata.test.ts

This file was deleted.

29 changes: 14 additions & 15 deletions src/compat/eme/custom_media_keys/ie11_media_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@
* limitations under the License.
*/

import {
merge as observableMerge,
Subject,
takeUntil,
} from "rxjs";
import EventEmitter from "../../../utils/event_emitter";
import TaskCanceller from "../../../utils/task_canceller";
import { ICompatHTMLMediaElement } from "../../browser_compatibility_types";
import * as events from "../../event_listeners";
import {
Expand All @@ -43,16 +39,16 @@ class IE11MediaKeySession
public expiration: number;
public keyStatuses: ICustomMediaKeyStatusMap;
private readonly _mk: MSMediaKeys;
private readonly _closeSession$: Subject<void>;
private readonly _sessionClosingCanceller: TaskCanceller;
private _ss: MSMediaKeySession | undefined;
constructor(mk: MSMediaKeys) {
super();
this.expiration = NaN;
this.keyStatuses = new Map();
this._mk = mk;
this._closeSession$ = new Subject();
this._sessionClosingCanceller = new TaskCanceller();
this.closed = new Promise((resolve) => {
this._closeSession$.subscribe(resolve);
this._sessionClosingCanceller.signal.register(() => resolve());
});
this.update = (license: Uint8Array) => {
return new Promise((resolve, reject) => {
Expand All @@ -79,11 +75,15 @@ class IE11MediaKeySession
initData instanceof ArrayBuffer ? new Uint8Array(initData) :
new Uint8Array(initData.buffer);
this._ss = this._mk.createSession("video/mp4", initDataU8);
observableMerge(events.onKeyMessage$(this._ss),
events.onKeyAdded$(this._ss),
events.onKeyError$(this._ss)
).pipe(takeUntil(this._closeSession$))
.subscribe((evt: Event) => this.trigger(evt.type, evt));
events.onKeyMessage(this._ss, (evt) => {
this.trigger((evt as Event).type ?? "message", evt as Event);
}, this._sessionClosingCanceller.signal);
events.onKeyAdded(this._ss, (evt) => {
this.trigger((evt as Event).type ?? "keyadded", evt as Event);
}, this._sessionClosingCanceller.signal);
events.onKeyError(this._ss, (evt) => {
this.trigger((evt as Event).type ?? "keyerror", evt as Event);
}, this._sessionClosingCanceller.signal);
resolve();
});
}
Expand All @@ -93,8 +93,7 @@ class IE11MediaKeySession
this._ss.close();
this._ss = undefined;
}
this._closeSession$.next();
this._closeSession$.complete();
this._sessionClosingCanceller.cancel();
resolve();
});
}
Expand Down
Loading

0 comments on commit 8e14c94

Please sign in to comment.