@@ -35,10 +35,20 @@ export const MediaParticleView = forwardRef<MediaParticleHandle, MediaParticleVi
|
|||||||
}, ref) {
|
}, ref) {
|
||||||
// Prefer the worker-produced iOS-playable variant when present so desktop
|
// Prefer the worker-produced iOS-playable variant when present so desktop
|
||||||
// and mobile read the same canonical asset. Falls back to the original.
|
// and mobile read the same canonical asset. Falls back to the original.
|
||||||
const activeObjectId =
|
// Pin the choice for the lifetime of this particle: if a transcoded variant
|
||||||
particle.properties.transcoded_object_id ?? particle.properties.object_id;
|
// arrives via Firestore mid-playback, swapping the <video> src would restart
|
||||||
const activeMime =
|
// playback from 0. Keep whatever we picked first; the original plays fine in
|
||||||
particle.properties.transcoded_mime_type ?? particle.properties.mime_type;
|
// Electron, and the transcoded variant will be picked up on the next view.
|
||||||
|
const pickedSourceRef = useRef<{ id: string; objectId: string; mime: string } | null>(null);
|
||||||
|
if (pickedSourceRef.current?.id !== particle.id) {
|
||||||
|
pickedSourceRef.current = {
|
||||||
|
id: particle.id,
|
||||||
|
objectId: particle.properties.transcoded_object_id ?? particle.properties.object_id,
|
||||||
|
mime: particle.properties.transcoded_mime_type ?? particle.properties.mime_type,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const activeObjectId = pickedSourceRef.current.objectId;
|
||||||
|
const activeMime = pickedSourceRef.current.mime;
|
||||||
const { data: url, error } = useDownloadUrl(activeObjectId);
|
const { data: url, error } = useDownloadUrl(activeObjectId);
|
||||||
const { attachments } = useParticleAttachments(streamPath, particle.id);
|
const { attachments } = useParticleAttachments(streamPath, particle.id);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user