diff --git a/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.jsx b/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.jsx index e4debc15..f67971d5 100644 --- a/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.jsx +++ b/net/web/src/User/Conversation/TopicItem/AudioAsset/AudioAsset.jsx @@ -46,7 +46,7 @@ export function AudioAsset({ label, audioUrl }) { if (!active) { return (
setActive(true)}> - +
) } @@ -65,7 +65,7 @@ export function AudioAsset({ label, audioUrl }) { if (height != dimension.height) { setDimension({ height }); } - return
+ return
}}
diff --git a/net/web/src/User/Conversation/TopicItem/TopicItem.jsx b/net/web/src/User/Conversation/TopicItem/TopicItem.jsx index 9589c19b..a79d5608 100644 --- a/net/web/src/User/Conversation/TopicItem/TopicItem.jsx +++ b/net/web/src/User/Conversation/TopicItem/TopicItem.jsx @@ -24,7 +24,8 @@ export function TopicItem({ topic }) { return } if (asset.video) { - return + return } if (asset.audio) { return diff --git a/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.jsx b/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.jsx index d1066091..8b218b94 100644 --- a/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.jsx +++ b/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.jsx @@ -1,59 +1,84 @@ -import React, { useEffect, useState } from 'react'; -import { Button } from 'antd'; +import React, { useRef, useEffect, useState } from 'react'; +import { Button, Modal } from 'antd'; import ReactPlayer from 'react-player' import ReactResizeDetector from 'react-resize-detector'; -import { PlayCircleOutlined } from '@ant-design/icons'; +import { SelectOutlined, ExpandOutlined, MinusCircleOutlined, PlayCircleOutlined } from '@ant-design/icons'; import { VideoAssetWrapper } from './VideoAsset.styled'; -export function VideoAsset({ thumbUrl, videoUrl }) { +export function VideoAsset({ thumbUrl, lqUrl, hdUrl }) { - const [active, setActive] = useState(false); - const [dimension, setDimension] = useState({}); - const [visibility, setVisibility] = useState('hidden'); - const [playing, setPlaying] = useState(false); + const [state, setState] = useState({}); + const player = useRef(null); + + const updateState = (value) => { + setState((s) => ({ ...s, ...value })); + } useEffect(() => { - setActive(false); - setVisibility('hidden'); - setPlaying(false); - }, [thumbUrl, videoUrl]); + }, [thumbUrl, hdUrl, lqUrl]); - const onReady = () => { - setPlaying(true); + const onFullScreen = () => { + updateState({ fullscreen: true, modalUrl: hdUrl, playing: false, url: null }); } - const onPlay = () => { - setVisibility('visible'); - } - - if (!thumbUrl) { - return - } - - const Player = () => { - if (!active) { + const CenterButton = () => { + if (!state.loaded) { return ( -
setActive(true)}> +
updateState({ loaded: true, url: lqUrl, controls: false, paused: true, playing: false })}> + +
+ ) + } + if (state.playing) { + return ( +
updateState({ playing: false })}> + +
+ ) + } + else { + return ( +
updateState({ playing: true })}>
) } - return + } + + const Controls = () => { + if (state.controls) { + return <>; + } + return ( +
+
+ +
+
onFullScreen()}> + +
+
+ ) } return ( {({ width, height }) => { - if (width != dimension.width || height != dimension.height) { - setDimension({ width, height }); + if (width != state.width || height != state.height) { + updateState({ width, height }); } return }} -
- +
+ +
+ { updateState({ fullscreen: false, modalUrl: null })}}> + + ) } diff --git a/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.styled.js b/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.styled.js index 3afbc638..a3459b28 100644 --- a/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.styled.js +++ b/net/web/src/User/Conversation/TopicItem/VideoAsset/VideoAsset.styled.js @@ -4,13 +4,46 @@ export const VideoAssetWrapper = styled.div` position: relative; height: 100%; - .player { + .playback { top: 0; position: absolute; display: flex; align-items: center; justify-content: center; } + + .player:hover .control { + visibility: visible; + } + + .player:hover .fullscreen { + visibility: visible; + } + + .player { + position: absolute; + top: 0; + } + + .control { + top: 0; + visibility: hidden; + position: absolute; + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + background-color: black; + opacity: 0.5; + } + + .fullscreen { + padding-right: 2px; + visibility: hidden; + position: absolute; + bottom: 0; + right: 0; + } `; - diff --git a/net/web/src/api/addChannelTopic.js b/net/web/src/api/addChannelTopic.js index 50ee1faa..3355e6b7 100644 --- a/net/web/src/api/addChannelTopic.js +++ b/net/web/src/api/addChannelTopic.js @@ -38,14 +38,15 @@ export async function addChannelTopic(token, channelId, message, assets ) { else if (asset.video) { const formData = new FormData(); formData.append('asset', asset.video); - let transform = encodeURIComponent(JSON.stringify(["vcopy;video", 'vthumb;video'])); + let transform = encodeURIComponent(JSON.stringify(["vlq;video", "vhd;video", 'vthumb;video'])); let topicAsset = await fetch(`/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&agent=${token}`, { method: 'POST', body: formData }); checkResponse(topicAsset); let assetEntry = await topicAsset.json(); message.assets.push({ video: { thumb: assetEntry.find(item => item.transform === 'vthumb;video').assetId, - full: assetEntry.find(item => item.transform === 'vcopy;video').assetId, + lq: assetEntry.find(item => item.transform === 'vlq;video').assetId, + hd: assetEntry.find(item => item.transform === 'vhd;video').assetId, } }); } diff --git a/net/web/src/api/addContactChannelTopic.js b/net/web/src/api/addContactChannelTopic.js index ffdcdb54..b82e85fd 100644 --- a/net/web/src/api/addContactChannelTopic.js +++ b/net/web/src/api/addContactChannelTopic.js @@ -39,14 +39,15 @@ export async function addContactChannelTopic(server, token, channelId, message, else if (asset.video) { const formData = new FormData(); formData.append('asset', asset.video); - let transform = encodeURIComponent(JSON.stringify(["vcopy;video", "vthumb;video"])); + let transform = encodeURIComponent(JSON.stringify(["vhd;video", "vlq;video", "vthumb;video"])); let topicAsset = await fetch(`https://${server}/content/channels/${channelId}/topics/${slot.id}/assets?transforms=${transform}&contact=${token}`, { method: 'POST', body: formData }); checkResponse(topicAsset); let assetEntry = await topicAsset.json(); message.assets.push({ video: { thumb: assetEntry.find(item => item.transform === 'vthumb;video').assetId, - full: assetEntry.find(item => item.transform === 'vcopy;video').assetId, + lq: assetEntry.find(item => item.transform === 'vlq;video').assetId, + hd: assetEntry.find(item => item.transform === 'vhd;video').assetId, } }); }