Hacks
This commit is contained in:
parent
3fc002f3fd
commit
6b5831dc1c
@ -32,7 +32,8 @@
|
|||||||
"react-native": "0.73.2",
|
"react-native": "0.73.2",
|
||||||
"react-native-windows": "^0.61.0-0",
|
"react-native-windows": "^0.61.0-0",
|
||||||
"release-it": "^16.2.1",
|
"release-it": "^16.2.1",
|
||||||
"typescript": "5.1.6"
|
"typescript": "5.1.6",
|
||||||
|
"patch-package": "^8.0.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"shaka-player": "^4.11.7"
|
"shaka-player": "^4.11.7"
|
||||||
@ -52,7 +53,8 @@
|
|||||||
"check-ios": "scripts/swift-format.sh && scripts/swift-lint.sh && scripts/clang-format.sh",
|
"check-ios": "scripts/swift-format.sh && scripts/swift-lint.sh && scripts/clang-format.sh",
|
||||||
"check-android": "scripts/kotlin-lint.sh",
|
"check-android": "scripts/kotlin-lint.sh",
|
||||||
"check-all": "yarn check-android; yarn check-ios; yarn lint",
|
"check-all": "yarn check-android; yarn check-ios; yarn lint",
|
||||||
"codegen": "node ./node_modules/react-native/scripts/generate-codegen-artifacts.js --path ./ ./output"
|
"codegen": "node ./node_modules/react-native/scripts/generate-codegen-artifacts.js --path ./ ./output",
|
||||||
|
"postinstall": "patch-package"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"android",
|
"android",
|
||||||
|
@ -6,7 +6,7 @@ import React, {
|
|||||||
useRef,
|
useRef,
|
||||||
type RefObject,
|
type RefObject,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import shaka from 'shaka-player/dist/shaka-player.ui';
|
import shaka from 'shaka-player';
|
||||||
import type { VideoRef, ReactVideoProps, VideoMetadata } from './types';
|
import type { VideoRef, ReactVideoProps, VideoMetadata } from './types';
|
||||||
|
|
||||||
const Video = forwardRef<VideoRef, ReactVideoProps>(
|
const Video = forwardRef<VideoRef, ReactVideoProps>(
|
||||||
@ -52,7 +52,6 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
|||||||
0,
|
0,
|
||||||
Math.min(time, shakaPlayerRef.current.seekRange().end)
|
Math.min(time, shakaPlayerRef.current.seekRange().end)
|
||||||
);
|
);
|
||||||
shakaPlayerRef.current.seek(time);
|
|
||||||
onSeek?.({
|
onSeek?.({
|
||||||
seekTime: time,
|
seekTime: time,
|
||||||
currentTime: nativeRef.current?.currentTime || 0,
|
currentTime: nativeRef.current?.currentTime || 0,
|
||||||
@ -224,7 +223,8 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
|||||||
shakaPlayerRef.current = player;
|
shakaPlayerRef.current = player;
|
||||||
|
|
||||||
// Error handling
|
// Error handling
|
||||||
player.addEventListener('error', (event: shaka.Event) => {
|
player.addEventListener('error', (event) => {
|
||||||
|
//@ts-ignore
|
||||||
const shakaError = event.detail;
|
const shakaError = event.detail;
|
||||||
console.error('Shaka Player Error', shakaError);
|
console.error('Shaka Player Error', shakaError);
|
||||||
onError?.({
|
onError?.({
|
||||||
@ -236,12 +236,14 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Buffering events
|
// Buffering events
|
||||||
player.addEventListener('buffering', (event: shaka.Event) => {
|
player.addEventListener('buffering', (event) => {
|
||||||
|
//@ts-ignore
|
||||||
onBuffer?.({ isBuffering: event.buffering });
|
onBuffer?.({ isBuffering: event.buffering });
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load the video source
|
// Load the video source
|
||||||
player
|
player
|
||||||
|
//@ts-ignore
|
||||||
.load(source?.uri)
|
.load(source?.uri)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
// Media loaded successfully
|
// Media loaded successfully
|
||||||
@ -262,8 +264,11 @@ const Video = forwardRef<VideoRef, ReactVideoProps>(
|
|||||||
duration,
|
duration,
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
naturalSize,
|
naturalSize,
|
||||||
|
//@ts-ignore
|
||||||
videoTracks: player.getVariantTracks(),
|
videoTracks: player.getVariantTracks(),
|
||||||
|
//@ts-ignore
|
||||||
audioTracks: player.getVariantTracks(),
|
audioTracks: player.getVariantTracks(),
|
||||||
|
//@ts-ignore
|
||||||
textTracks: player.getTextTracks(),
|
textTracks: player.getTextTracks(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user