mirror of
https://github.com/jellyfin/jellyfin-expo.git
synced 2024-11-27 00:00:26 +00:00
Fix reporting playback progress on local files
This commit is contained in:
parent
c18d5cf063
commit
9b67045a19
@ -136,6 +136,7 @@ const DownloadScreen = observer(() => {
|
||||
}}
|
||||
onPlay={async () => {
|
||||
item.isNew = false;
|
||||
rootStore.mediaStore.isLocalFile = true;
|
||||
rootStore.mediaStore.type = MediaTypes.Video;
|
||||
rootStore.mediaStore.uri = item.uri;
|
||||
}}
|
||||
|
@ -58,26 +58,29 @@ const HomeScreen = observer(() => {
|
||||
}, [ webview ])
|
||||
);
|
||||
|
||||
// Report media updates to the video plugin
|
||||
// Report media updates to the audio/video plugin
|
||||
useEffect(() => {
|
||||
const status = {
|
||||
didPlayerCloseManually: rootStore.didPlayerCloseManually,
|
||||
uri: rootStore.mediaStore.uri,
|
||||
isFinished: rootStore.mediaStore.isFinished,
|
||||
isPlaying: rootStore.mediaStore.isPlaying,
|
||||
positionTicks: rootStore.mediaStore.positionTicks,
|
||||
positionMillis: rootStore.mediaStore.positionMillis
|
||||
};
|
||||
if (!rootStore.mediaStore.isLocalFile) {
|
||||
const status = {
|
||||
didPlayerCloseManually: rootStore.didPlayerCloseManually,
|
||||
uri: rootStore.mediaStore.uri,
|
||||
isFinished: rootStore.mediaStore.isFinished,
|
||||
isPlaying: rootStore.mediaStore.isPlaying,
|
||||
positionTicks: rootStore.mediaStore.positionTicks,
|
||||
positionMillis: rootStore.mediaStore.positionMillis
|
||||
};
|
||||
|
||||
if (rootStore.mediaStore.type === MediaTypes.Audio) {
|
||||
webview.current?.injectJavaScript(`window.ExpoAudioPlayer && window.ExpoAudioPlayer._reportStatus(${JSON.stringify(status)});`);
|
||||
} else if (rootStore.mediaStore.type === MediaTypes.Video) {
|
||||
webview.current?.injectJavaScript(`window.ExpoVideoPlayer && window.ExpoVideoPlayer._reportStatus(${JSON.stringify(status)});`);
|
||||
if (rootStore.mediaStore.type === MediaTypes.Audio) {
|
||||
webview.current?.injectJavaScript(`window.ExpoAudioPlayer && window.ExpoAudioPlayer._reportStatus(${JSON.stringify(status)});`);
|
||||
} else if (rootStore.mediaStore.type === MediaTypes.Video) {
|
||||
webview.current?.injectJavaScript(`window.ExpoVideoPlayer && window.ExpoVideoPlayer._reportStatus(${JSON.stringify(status)});`);
|
||||
}
|
||||
}
|
||||
}, [
|
||||
rootStore.mediaStore.type,
|
||||
rootStore.mediaStore.uri,
|
||||
rootStore.mediaStore.isFinished,
|
||||
rootStore.mediaStore.isLocalFile,
|
||||
rootStore.mediaStore.isPlaying,
|
||||
rootStore.mediaStore.positionTicks
|
||||
]);
|
||||
|
@ -24,6 +24,11 @@ export default class MediaStore {
|
||||
*/
|
||||
isFinished = false
|
||||
|
||||
/**
|
||||
* Is the media a local file (not streaming media)
|
||||
*/
|
||||
isLocalFile = false
|
||||
|
||||
/**
|
||||
* Is the media currently playing
|
||||
*/
|
||||
@ -57,6 +62,7 @@ export default class MediaStore {
|
||||
this.type = null;
|
||||
this.uri = null;
|
||||
this.isFinished = false;
|
||||
this.isLocalFile = false;
|
||||
this.isPlaying = false;
|
||||
this.positionTicks = 0;
|
||||
this.backdropUri = null;
|
||||
@ -69,6 +75,7 @@ decorate(MediaStore, {
|
||||
type: [ ignore, observable ],
|
||||
uri: [ ignore, observable ],
|
||||
isFinished: [ ignore, observable ],
|
||||
isLocalFile: [ ignore, observable ],
|
||||
isPlaying: [ ignore, observable ],
|
||||
positionTicks: [ ignore, observable ],
|
||||
positionMillis: computed,
|
||||
|
@ -13,6 +13,7 @@ describe('MediaStore', () => {
|
||||
expect(store.type).toBeUndefined();
|
||||
expect(store.uri).toBeUndefined();
|
||||
expect(store.isFinished).toBe(false);
|
||||
expect(store.isLocalFile).toBe(false);
|
||||
expect(store.isPlaying).toBe(false);
|
||||
expect(store.positionTicks).toBe(0);
|
||||
expect(store.positionMillis).toBe(0);
|
||||
@ -26,6 +27,7 @@ describe('MediaStore', () => {
|
||||
store.type = MediaTypes.Video;
|
||||
store.uri = 'https://foobar';
|
||||
store.isFinished = true;
|
||||
store.isLocalFile = true;
|
||||
store.isPlaying = true;
|
||||
store.positionTicks = 3423000;
|
||||
store.backdropUri = 'https://foobar';
|
||||
@ -35,6 +37,7 @@ describe('MediaStore', () => {
|
||||
expect(store.type).toBe(MediaTypes.Video);
|
||||
expect(store.uri).toBe('https://foobar');
|
||||
expect(store.isFinished).toBe(true);
|
||||
expect(store.isLocalFile).toBe(true);
|
||||
expect(store.isPlaying).toBe(true);
|
||||
expect(store.positionTicks).toBe(3423000);
|
||||
expect(store.positionMillis).toBe(342.3);
|
||||
@ -46,6 +49,7 @@ describe('MediaStore', () => {
|
||||
expect(store.type).toBeNull();
|
||||
expect(store.uri).toBeNull();
|
||||
expect(store.isFinished).toBe(false);
|
||||
expect(store.isLocalFile).toBe(false);
|
||||
expect(store.isPlaying).toBe(false);
|
||||
expect(store.positionTicks).toBe(0);
|
||||
expect(store.positionMillis).toBe(0);
|
||||
|
Loading…
Reference in New Issue
Block a user