Skip to content

Commit c985ed3

Browse files
committed
fix: add suggestions
1 parent b76f3b1 commit c985ed3

File tree

4 files changed

+8
-25
lines changed

4 files changed

+8
-25
lines changed

src/components/media/audio/sound.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,9 @@ export default function Sound(props: AudioFormat) {
233233
{renderVideoElement()}
234234
{renderControls()}
235235
<Fade in={controlErrorMessage.length > 0}>
236-
<Alert severity="error">{controlErrorMessage}</Alert>
236+
<Alert severity="error" onClose={() => setControlErrorMessage('')}>
237+
{controlErrorMessage}
238+
</Alert>
237239
</Fade>
238240
</Box>
239241
)

src/components/media/controls/commonControls.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,9 @@ export function PlayOrPauseButton(props: PlayOrPauseButtonProps) {
169169
if (isPlaying) {
170170
props.mediaElement.pause()
171171
} else {
172-
props.mediaElement
173-
.play()
174-
.then(() => {
175-
props.onError('')
176-
})
177-
.catch(() => {
178-
props.onError('Failed to play the media. Please try again.')
179-
})
172+
props.mediaElement.play().catch(() => {
173+
props.onError('Failed to play the media. Please try again.')
174+
})
180175
}
181176
}
182177

src/components/media/controls/videoControls.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export function PictureInPictureButton(props: PictureInPictureButtonProps) {
2828
document
2929
.exitPictureInPicture()
3030
.then(() => {
31-
props.onError('')
3231
setIsPictureInPicture(false)
3332
})
3433
.catch(() => {
@@ -40,7 +39,6 @@ export function PictureInPictureButton(props: PictureInPictureButtonProps) {
4039
videoElement
4140
.requestPictureInPicture()
4241
.then(() => {
43-
props.onError('')
4442
setIsPictureInPicture(true)
4543
})
4644
.catch(() => {
@@ -69,7 +67,6 @@ export function FullscreenButton(props: FullscreenButtonProps) {
6967
document
7068
.exitFullscreen()
7169
.then(() => {
72-
props.onError('')
7370
setIsFullscreen(false)
7471
})
7572
.catch(() => {
@@ -79,7 +76,6 @@ export function FullscreenButton(props: FullscreenButtonProps) {
7976
props.element
8077
.requestFullscreen()
8178
.then(() => {
82-
props.onError('')
8379
setIsFullscreen(true)
8480
})
8581
.catch(() => {

src/components/media/video/video.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,7 @@ export default function Video(props: VideoFormat) {
7272
})
7373
}, [])
7474

75-
function adjustHexColorOpacity(color: string, opacity: number) {
76-
const r = parseInt(color.slice(1, 3), 16)
77-
const g = parseInt(color.slice(3, 5), 16)
78-
const b = parseInt(color.slice(5, 7), 16)
79-
80-
return `rgba(${r}, ${g}, ${b}, ${opacity})`
81-
}
82-
83-
const backgroundColor = adjustHexColorOpacity(
84-
theme.palette.background.paper,
85-
0.6
86-
)
75+
const backgroundColor = theme.palette.background.paper
8776

8877
function renderVideoElement() {
8978
return (
@@ -314,6 +303,7 @@ export default function Video(props: VideoFormat) {
314303
severity="error"
315304
className="rustic-video-control-error-message"
316305
data-cy="control-error-message"
306+
onClose={() => setControlErrorMessage('')}
317307
>
318308
{controlErrorMessage}
319309
</Alert>

0 commit comments

Comments
 (0)