Spaces:
Running
Running
File size: 2,933 Bytes
b4f9490 ae94c0d b4f9490 ae94c0d b4f9490 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
import { defineStore } from 'pinia'
export const useVideoStore = defineStore('video', {
state: () => ({
videos: [],
selectedVideo: null,
defaultPath: 'C:\\Users\\antoi\\Documents\\Work_Learn\\Stage-Rennes\\RepositoryFootballVision\\SportDETR\\data\\football\\raw',
// defaultPath: '\\\\10.35.51.152\\Biomeca\\Projets\\25_EVA2PERF_M2_AntoineVerdon\\RepositoryFootballVision\\SportDETR\\data\\football\\raw',
currentTime: 0,
isPlaying: false,
duration: 0,
fps: 25, // FPS par défaut changé à 25
// Vidéo par défaut depuis les assets
defaultVideo: null,
isInitialized: false
}),
actions: {
// Initialiser avec une vidéo par défaut si aucune n'est sélectionnée
async initialize() {
if (!this.isInitialized && !this.selectedVideo) {
// Essayer de charger une vidéo par défaut depuis les assets
try {
const defaultVideoPath = require('@/assets/football.mp4')
this.defaultVideo = {
name: 'football',
path: defaultVideoPath,
type: 'video/mp4',
isDefault: true
}
// Ne pas définir automatiquement comme selectedVideo, laisser l'utilisateur choisir
} catch (error) {
console.log('Aucune vidéo par défaut disponible dans les assets')
}
this.isInitialized = true
}
},
setVideos(videos) {
this.videos = videos
},
async setSelectedVideo(video) {
this.selectedVideo = video
},
setCurrentTime(time) {
this.currentTime = time
},
setIsPlaying(isPlaying) {
this.isPlaying = isPlaying
},
setDuration(duration) {
this.duration = duration
},
setFps(fps) {
this.fps = fps
console.log('FPS défini à:', fps)
},
async loadVideosFromFolder() {
// DÉSACTIVÉ - pas de chargement de dossier externe
this.videos = []
return []
},
async loadVideoMetadata(videoPath) {
return new Promise((resolve, reject) => {
const tempVideo = document.createElement('video')
tempVideo.src = videoPath
tempVideo.crossOrigin = 'anonymous'
tempVideo.addEventListener('loadedmetadata', () => {
this.duration = tempVideo.duration
resolve({
duration: tempVideo.duration,
videoElement: tempVideo
})
})
tempVideo.addEventListener('error', (error) => {
console.error('Erreur lors du chargement de la vidéo:', error)
reject(error)
})
})
},
updateProgressBar(time) {
this.currentTime = time
this.emitTimeUpdate(time)
},
emitTimeUpdate(time) {
this.currentTime = time
}
}
}) |