diff --git a/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.jsx b/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.jsx index 163ee7cb..1af945cb 100644 --- a/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.jsx +++ b/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.jsx @@ -1,8 +1,50 @@ import React, { useEffect, useState } from 'react'; +import { Button } from 'antd'; import ReactPlayer from 'react-player' +import ReactResizeDetector from 'react-resize-detector'; +import { SoundOutlined } from '@ant-design/icons'; +import { AudioAssetWrapper } from './AudioAsset.styled'; export function AudioAsset({ label, audioUrl }) { - return + const [active, setActive] = useState(false); + const [dimension, setDimension] = useState({}); + const [playing, setPlaying] = useState(false); + + useEffect(() => { + setActive(false); + setPlaying(false); + }, [label, audioUrl]); + + const onReady = () => { + setPlaying(true); + } + + const Player = () => { + if (!active) { + return ( +
setActive(true)}> + +
+ ) + } + return + } + + return ( + + + {({ height }) => { + if (height != dimension.height) { + setDimension({ height }); + } + return
+ }} + +
+ +
+ + ) } diff --git a/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.styled.js b/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.styled.js new file mode 100644 index 00000000..c31489ab --- /dev/null +++ b/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.styled.js @@ -0,0 +1,16 @@ +import styled from 'styled-components'; + +export const AudioAssetWrapper = styled.div` + position: relative; + height: 100%; + + .player { + top: 0; + position: absolute; + display: flex; + align-items: center; + justify-content: center; + } +`; + + diff --git a/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.jsx b/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.jsx index c9c3c371..d1066091 100644 --- a/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.jsx +++ b/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.jsx @@ -19,10 +19,13 @@ export function VideoAsset({ thumbUrl, videoUrl }) { }, [thumbUrl, videoUrl]); const onReady = () => { - setVisibility('visible'); setPlaying(true); } + const onPlay = () => { + setVisibility('visible'); + } + if (!thumbUrl) { return } @@ -35,7 +38,7 @@ export function VideoAsset({ thumbUrl, videoUrl }) {
) } - return + return } return (