Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
[akkoma] / lib / pleroma / web / metadata / player_view.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.Metadata.PlayerView do
6 use Pleroma.Web, :view
7 import Phoenix.HTML.Tag, only: [content_tag: 3, tag: 2]
8
9 def render("player.html", %{"mediaType" => type, "href" => href}) do
10 {tag_type, tag_attrs} =
11 case type do
12 "audio" <> _ -> {:audio, []}
13 "video" <> _ -> {:video, [loop: true]}
14 end
15
16 content_tag(
17 tag_type,
18 [
19 tag(:source, src: href, type: type),
20 "Your browser does not support #{type} playback."
21 ],
22 [controls: true] ++ tag_attrs
23 )
24 end
25 end