File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change 33import { useState } from 'react'
44import clsx from 'clsx'
55import type { MediaAnimatedGif , MediaVideo } from '../api/index.js'
6- import { EnrichedQuotedTweet , type EnrichedTweet , getMediaUrl , getMp4Video } from '../utils.js'
6+ import {
7+ EnrichedQuotedTweet ,
8+ type EnrichedTweet ,
9+ getMediaUrl ,
10+ getMp4Video ,
11+ } from '../utils.js'
712import mediaStyles from './tweet-media.module.css'
813import s from './tweet-media-video.module.css'
914
@@ -25,7 +30,7 @@ export const TweetMediaVideo = ({ tweet, media }: Props) => {
2530 className = { mediaStyles . image }
2631 poster = { getMediaUrl ( media , 'small' ) }
2732 controls = { ! playButton }
28- muted
33+ playsInline
2934 preload = "none"
3035 tabIndex = { playButton ? - 1 : 0 }
3136 onPlay = { ( ) => {
@@ -59,9 +64,18 @@ export const TweetMediaVideo = ({ tweet, media }: Props) => {
5964
6065 e . preventDefault ( )
6166 setPlayButton ( false )
62- setIsPlaying ( true )
63- video . play ( )
64- video . focus ( )
67+ video . load ( )
68+ video
69+ . play ( )
70+ . then ( ( ) => {
71+ setIsPlaying ( true )
72+ video . focus ( )
73+ } )
74+ . catch ( ( error ) => {
75+ console . error ( 'Error playing video:' , error )
76+ setPlayButton ( true )
77+ setIsPlaying ( false )
78+ } )
6579 } }
6680 >
6781 < svg
You can’t perform that action at this time.
0 commit comments