mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
Basic support for HLS added
This commit is contained in:
parent
32f8b652ad
commit
072123af8f
23 changed files with 128365 additions and 13 deletions
|
@ -3687,7 +3687,7 @@ class Item
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($PostMedia->mimetype->type == 'video') {
|
||||
if (($PostMedia->mimetype->type == 'video') || ($PostMedia->type == Post\Media::HLS)) {
|
||||
if (($PostMedia->height ?? 0) > ($PostMedia->width ?? 0)) {
|
||||
$height = min(DI::config()->get('system', 'max_video_height') ?: '100%', $PostMedia->height);
|
||||
$width = 'auto';
|
||||
|
@ -3696,7 +3696,7 @@ class Item
|
|||
$width = '100%';
|
||||
}
|
||||
/// @todo Move the template to /content as well
|
||||
$media = Renderer::replaceMacros(Renderer::getMarkupTemplate('video_top.tpl'), [
|
||||
$media = Renderer::replaceMacros(Renderer::getMarkupTemplate($PostMedia->type == Post\Media::HLS ? 'hls_top.tpl' : 'video_top.tpl'), [
|
||||
'$video' => [
|
||||
'id' => $PostMedia->id,
|
||||
'src' => (string)$PostMedia->url,
|
||||
|
|
|
@ -345,7 +345,7 @@ class Engagement
|
|||
foreach ($media as $entry) {
|
||||
if ($entry['type'] == Post\Media::IMAGE) {
|
||||
$type = $type | self::MEDIA_IMAGE;
|
||||
} elseif ($entry['type'] == Post\Media::VIDEO) {
|
||||
} elseif (in_array($entry['type'], [Post\Media::VIDEO, Post\Media::HLS])) {
|
||||
$type = $type | self::MEDIA_VIDEO;
|
||||
} elseif ($entry['type'] == Post\Media::AUDIO) {
|
||||
$type = $type | self::MEDIA_AUDIO;
|
||||
|
|
|
@ -50,6 +50,7 @@ class Media
|
|||
const PLAIN = 19;
|
||||
const ACTIVITY = 20;
|
||||
const ACCOUNT = 21;
|
||||
const HLS = 22;
|
||||
const DOCUMENT = 128;
|
||||
|
||||
/**
|
||||
|
@ -220,19 +221,16 @@ class Media
|
|||
} else {
|
||||
Logger::notice('No image data', ['media' => $media]);
|
||||
}
|
||||
if (!empty($media['preview'])) {
|
||||
$imagedata = Images::getInfoFromURLCached($media['preview']);
|
||||
if ($imagedata) {
|
||||
$media['preview-width'] = $imagedata[0];
|
||||
$media['preview-height'] = $imagedata[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($media['type'] != self::DOCUMENT) {
|
||||
$media = self::addType($media);
|
||||
}
|
||||
|
||||
if (!empty($media['preview'])) {
|
||||
$media = self::addPreviewData($media);
|
||||
}
|
||||
|
||||
if (in_array($media['type'], [self::TEXT, self::APPLICATION, self::HTML, self::XML, self::PLAIN])) {
|
||||
$media = self::addActivity($media);
|
||||
}
|
||||
|
@ -248,6 +246,21 @@ class Media
|
|||
return $media;
|
||||
}
|
||||
|
||||
private static function addPreviewData(array $media): array
|
||||
{
|
||||
if (!empty($media['preview-width']) && !empty($media['preview-height'])) {
|
||||
return $media;
|
||||
}
|
||||
|
||||
$imagedata = Images::getInfoFromURLCached($media['preview']);
|
||||
if ($imagedata) {
|
||||
$media['preview-width'] = $imagedata[0];
|
||||
$media['preview-height'] = $imagedata[1];
|
||||
}
|
||||
|
||||
return $media;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the activity type if the media entry is linked to an activity
|
||||
*
|
||||
|
@ -466,6 +479,8 @@ class Media
|
|||
$type = self::TEXT;
|
||||
} elseif (($filetype == 'application') && ($subtype == 'x-bittorrent')) {
|
||||
$type = self::TORRENT;
|
||||
} elseif (($filetype == 'application') && ($subtype == 'vnd.apple.mpegurl')) {
|
||||
$type = self::HLS;
|
||||
} elseif ($filetype == 'application') {
|
||||
$type = self::APPLICATION;
|
||||
} else {
|
||||
|
@ -473,8 +488,8 @@ class Media
|
|||
Logger::info('Unknown type', ['filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]);
|
||||
}
|
||||
|
||||
Logger::debug('Detected type', ['filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]);
|
||||
return $type;
|
||||
Logger::debug('Detected type', ['type' => $type, 'filetype' => $filetype, 'subtype' => $subtype, 'media' => $mimeType]);
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue