mirror of
https://github.com/overte-org/overte.git
synced 2025-07-28 01:40:11 +02:00
Basic video support.
This commit is contained in:
parent
8ac598886f
commit
71c85d3889
2 changed files with 46 additions and 3 deletions
|
@ -74,9 +74,13 @@ const formatting = {
|
||||||
const res = await formatting.helpers.fetch(url, {method: 'GET'}); // TODO: Replace with 'HEAD' method. https://github.com/overte-org/overte/issues/1273
|
const res = await formatting.helpers.fetch(url, {method: 'GET'}); // TODO: Replace with 'HEAD' method. https://github.com/overte-org/overte/issues/1273
|
||||||
const contentType = res.getResponseHeader("content-type");
|
const contentType = res.getResponseHeader("content-type");
|
||||||
|
|
||||||
// TODO: Add support for other media types
|
|
||||||
if (contentType.startsWith('image/')) {
|
if (contentType.startsWith('image/')) {
|
||||||
messageArray.push({type: 'imageEmbed', value: url});
|
messageArray.push({type: 'imageEmbed', value: url});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (contentType.startsWith('video/')){
|
||||||
|
messageArray.push({type: 'videoEmbed', value: url});
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,7 +148,6 @@ const formatting = {
|
||||||
|
|
||||||
if (req.readyState === req.DONE) {
|
if (req.readyState === req.DONE) {
|
||||||
if (req.status === 200) {
|
if (req.status === 200) {
|
||||||
console.log("Content type:", req.getResponseHeader("content-type"));
|
|
||||||
resolve(req);
|
resolve(req);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
import QtQuick.Layouts 1.3
|
import QtQuick.Layouts 1.3
|
||||||
|
import QtMultimedia 5.15
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: template_chat_message
|
id: template_chat_message
|
||||||
|
@ -150,10 +151,49 @@ Component {
|
||||||
AnimatedImage {
|
AnimatedImage {
|
||||||
source: model.type === 'imageEmbed' ? model.value : ''
|
source: model.type === 'imageEmbed' ? model.value : ''
|
||||||
height: Math.min(sourceSize.height, 200);
|
height: Math.min(sourceSize.height, 200);
|
||||||
onStatusChanged: playing = (status == AnimatedImage.Ready)
|
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
visible: model.type === 'videoEmbed';
|
||||||
|
width: messageBoxFlow.width;
|
||||||
|
height: 200;
|
||||||
|
|
||||||
|
Video {
|
||||||
|
id: videoPlayer
|
||||||
|
source: model.type === 'videoEmbed' ? model.value : ''
|
||||||
|
height: 200;
|
||||||
|
width: 400;
|
||||||
|
fillMode: Image.PreserveAspectFit
|
||||||
|
autoLoad: false;
|
||||||
|
|
||||||
|
onStatusChanged: {
|
||||||
|
if (status === 7) {
|
||||||
|
// Weird hack to make the video restart when it's over
|
||||||
|
// Ideally you'd want to use the seek function to restart the video but it doesn't work?
|
||||||
|
// Will need to make a more refined solution for this later. in the form of a more advanced media player.
|
||||||
|
// For now, this is sufficient. -AD
|
||||||
|
let originalURL = videoPlayer.source;
|
||||||
|
videoPlayer.source = "";
|
||||||
|
videoPlayer.source = originalURL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
onClicked: {
|
||||||
|
const videoIsOver = videoPlayer.position == videoPlayer.duration
|
||||||
|
if (videoPlayer.playbackState == MediaPlayer.PlayingState) {
|
||||||
|
videoPlayer.pause();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
parent.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue