summaryrefslogtreecommitdiff
path: root/lib/pleroma/web/metadata/player_view.ex
blob: 9be5e433d4d15d0972ab8492b9136774f1963227 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only

defmodule Pleroma.Web.Metadata.PlayerView do
  use Pleroma.Web, :view
  import Phoenix.HTML.Tag, only: [content_tag: 3, tag: 2]

  def render("player.html", %{"mediaType" => type, "href" => href}) do
    {tag_type, tag_attrs} =
      case type do
        "audio" <> _ -> {:audio, []}
        "video" <> _ -> {:video, [loop: true]}
      end

    content_tag(
      tag_type,
      [
        tag(:source, src: href, type: type),
        "Your browser does not support #{type} playback."
      ],
      [controls: true] ++ tag_attrs
    )
  end
end