mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-15 05:36:17 -08:00
101 lines
2.9 KiB
TypeScript
101 lines
2.9 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { PlaybackPositionData } from '@iptvnator/shared/interfaces';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class PlaybackPositionService {
|
|
async savePlaybackPosition(
|
|
playlistId: string,
|
|
data: PlaybackPositionData
|
|
): Promise<void> {
|
|
try {
|
|
await window.electron.dbSavePlaybackPosition(playlistId, data);
|
|
} catch (error) {
|
|
console.error('Error saving playback position:', error);
|
|
}
|
|
}
|
|
|
|
async getPlaybackPosition(
|
|
playlistId: string,
|
|
contentXtreamId: number,
|
|
contentType: 'vod' | 'episode'
|
|
): Promise<PlaybackPositionData | null> {
|
|
try {
|
|
return await window.electron.dbGetPlaybackPosition(
|
|
playlistId,
|
|
contentXtreamId,
|
|
contentType
|
|
);
|
|
} catch (error) {
|
|
console.error('Error getting playback position:', error);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
async getSeriesPlaybackPositions(
|
|
playlistId: string,
|
|
seriesXtreamId: number
|
|
): Promise<PlaybackPositionData[]> {
|
|
try {
|
|
return await window.electron.dbGetSeriesPlaybackPositions(
|
|
playlistId,
|
|
seriesXtreamId
|
|
);
|
|
} catch (error) {
|
|
console.error('Error getting series playback positions:', error);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
async getRecentPlaybackPositions(
|
|
playlistId: string,
|
|
limit?: number
|
|
): Promise<PlaybackPositionData[]> {
|
|
try {
|
|
return await window.electron.dbGetRecentPlaybackPositions(
|
|
playlistId,
|
|
limit
|
|
);
|
|
} catch (error) {
|
|
console.error('Error getting recent playback positions:', error);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
async getAllPlaybackPositions(
|
|
playlistId: string
|
|
): Promise<PlaybackPositionData[]> {
|
|
try {
|
|
return await window.electron.dbGetAllPlaybackPositions(playlistId);
|
|
} catch (error) {
|
|
console.error('Error getting all playback positions:', error);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
async clearAllPlaybackPositions(playlistId: string): Promise<void> {
|
|
try {
|
|
await window.electron.dbClearAllPlaybackPositions(playlistId);
|
|
} catch (error) {
|
|
console.error('Error clearing all playback positions:', error);
|
|
}
|
|
}
|
|
|
|
async clearPlaybackPosition(
|
|
playlistId: string,
|
|
contentXtreamId: number,
|
|
contentType: 'vod' | 'episode'
|
|
): Promise<void> {
|
|
try {
|
|
await window.electron.dbClearPlaybackPosition(
|
|
playlistId,
|
|
contentXtreamId,
|
|
contentType
|
|
);
|
|
} catch (error) {
|
|
console.error('Error clearing playback position:', error);
|
|
}
|
|
}
|
|
}
|