1
0

player.html.haml 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. - content_for :header_tags do
  2. = render_initial_state
  3. = javascript_pack_tag 'public', crossorigin: 'anonymous'
  4. - content_for :body_classes, 'player'
  5. :ruby
  6. meta = @media_attachment.file.meta || {}
  7. - if @media_attachment.video?
  8. = react_component :video,
  9. alt: @media_attachment.description,
  10. blurhash: @media_attachment.blurhash,
  11. detailed: true,
  12. editable: true,
  13. frameRate: meta.dig('original', 'frame_rate'),
  14. height: 380,
  15. inline: true,
  16. media: [ActiveModelSerializers::SerializableResource.new(@media_attachment, serializer: REST::MediaAttachmentSerializer)].as_json,
  17. preview: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.file.url(:small),
  18. src: @media_attachment.file.url(:original),
  19. width: 670 do
  20. %video{ controls: 'controls' }
  21. %source{ src: @media_attachment.file.url(:original) }
  22. - elsif @media_attachment.gifv?
  23. = react_component :media_gallery,
  24. autoplay: true,
  25. height: 380,
  26. media: [ActiveModelSerializers::SerializableResource.new(@media_attachment, serializer: REST::MediaAttachmentSerializer).as_json],
  27. standalone: true do
  28. %video{ autoplay: 'autoplay', muted: 'muted', loop: 'loop' }
  29. %source{ src: @media_attachment.file.url(:original) }
  30. - elsif @media_attachment.audio?
  31. = react_component :audio,
  32. accentColor: meta.dig('colors', 'accent'),
  33. alt: @media_attachment.description,
  34. backgroundColor: meta.dig('colors', 'background'),
  35. duration: meta.dig(:original, :duration),
  36. foregroundColor: meta.dig('colors', 'foreground'),
  37. fullscreen: true,
  38. height: 380,
  39. poster: @media_attachment.thumbnail.present? ? @media_attachment.thumbnail.url : @media_attachment.account.avatar_static_url,
  40. src: @media_attachment.file.url(:original),
  41. width: 670 do
  42. %audio{ controls: 'controls' }
  43. %source{ src: @media_attachment.file.url(:original) }