fix(ymb): refresh shorts playback sources
This commit is contained in:
1 parent
535bb57c83
commit
ebf7886485
5 files changed
+71
-9
No files matched your search
@@ -139,6 +139,7 @@ export function ShortsFeedPage() {
|
||||
onToggleFollow={() => toggleFollow(video.channel)}
|
||||
onOpenComments={() => setCommentsVideo(video)}
|
||||
onShare={() => shareVideo(video)}
|
||||
onEnded={() => move(1)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -3,12 +3,28 @@ import { Bookmark, MessageCircle, Share2, ThumbsUp } from 'lucide-react';
|
||||
import { useLocale } from '../../../app/providers/AppProviders';
|
||||
import { VideoPlayer } from '../../../shared/components/player/VideoPlayer';
|
||||
import { useEngagement } from '../../../shared/hooks/useEngagement';
|
||||
import { useRequest } from '../../../shared/hooks/useRequest';
|
||||
import { formatCount } from '../../../shared/lib/format';
|
||||
import { selectPlaybackUrl } from '../../../shared/lib/media';
|
||||
import { reportWatchProgress } from '../../../shared/lib/watchProgress';
|
||||
import { dramaApi } from '../../../entities/drama/api';
|
||||
|
||||
export function ShortSlide({ video, active, followed, onToggleFollow, onOpenComments, onShare }) {
|
||||
export function ShortSlide({ video, active, followed, onToggleFollow, onOpenComments, onShare, onEnded }) {
|
||||
const { locale } = useLocale();
|
||||
const src = video.preview?.playUrl;
|
||||
const previewId = video.preview?.id ? String(video.preview.id) : '';
|
||||
const fallbackSrc = video.preview?.playUrl || '';
|
||||
const playback = useRequest(
|
||||
({ signal }) => dramaApi.playback(previewId, { signal }),
|
||||
[active, previewId],
|
||||
{ enabled: active && Boolean(previewId) },
|
||||
);
|
||||
const src = active
|
||||
? playback.data
|
||||
? selectPlaybackUrl(playback.data, fallbackSrc)
|
||||
: playback.error
|
||||
? fallbackSrc
|
||||
: ''
|
||||
: '';
|
||||
const likeTargetId = video.preview?.id || video.id;
|
||||
const { liked, likeCount, saved, saveCount, toggleLike, toggleSave } = useEngagement({
|
||||
likeTargetType: video.preview?.id ? 'EPISODE' : 'DRAMA',
|
||||
@@ -33,8 +49,8 @@ export function ShortSlide({ video, active, followed, onToggleFollow, onOpenComm
|
||||
<div className="short-player-wrap">
|
||||
<div className="short-slide-player">
|
||||
{src
|
||||
? <VideoPlayer src={src} poster={video.image} autoPlay={active} soundHint={locale.soundHint} onProgress={(position, duration, flush) => reportWatchProgress(video.preview?.id, position, duration, 'shorts', flush)} />
|
||||
: <div className="short-slide-placeholder"><img src={video.image} alt={video.title} /><span>{video.title}</span></div>}
|
||||
? <VideoPlayer src={src} poster={video.image} autoPlay={active} soundHint={locale.soundHint} onEnded={onEnded} onProgress={(position, duration, flush) => reportWatchProgress(video.preview?.id, position, duration, 'shorts', flush)} />
|
||||
: <div className="short-slide-placeholder"><img src={video.image} alt={video.title} /><span>{active && playback.loading ? locale.loading : active && playback.error ? locale.playbackUnavailable : video.title}</span></div>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user