VideoPresenter.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <template>
  2. <div v-if="status.sensitive == true" class="content-label-wrapper">
  3. <div class="text-light content-label">
  4. <p class="text-center">
  5. <i class="far fa-eye-slash fa-2x"></i>
  6. </p>
  7. <p class="h4 font-weight-bold text-center">
  8. Sensitive Content
  9. </p>
  10. <p class="text-center py-2 content-label-text">
  11. {{ status.spoiler_text ? status.spoiler_text : 'This post may contain sensitive content.'}}
  12. </p>
  13. <p class="mb-0">
  14. <button @click="toggleContentWarning()" class="btn btn-outline-light btn-block btn-sm font-weight-bold">See Post</button>
  15. </p>
  16. </div>
  17. <blur-hash-image
  18. width="32"
  19. height="32"
  20. :punch="1"
  21. :hash="status.media_attachments[0].blurhash"
  22. :alt="altText(status)"/>
  23. </div>
  24. <div v-else class="embed-responsive embed-responsive-16by9">
  25. <video class="video" controls playsinline preload="metadata" loop :data-id="status.id">
  26. <source :src="status.media_attachments[0].url" :type="status.media_attachments[0].mime">
  27. </video>
  28. </div>
  29. </template>
  30. <style type="text/css" scoped>
  31. .content-label-wrapper {
  32. position: relative;
  33. }
  34. .content-label {
  35. margin: 0;
  36. position: absolute;
  37. top:50%;
  38. left:50%;
  39. transform: translate(-50%, -50%);
  40. display: flex;
  41. flex-direction: column;
  42. align-items: center;
  43. justify-content: center;
  44. width: 100%;
  45. height: 100%;
  46. z-index: 2;
  47. background: rgba(0, 0, 0, 0.2)
  48. }
  49. </style>
  50. <script type="text/javascript">
  51. export default {
  52. props: ['status'],
  53. methods: {
  54. altText(status) {
  55. let desc = status.media_attachments[0].description;
  56. if(desc) {
  57. return desc;
  58. }
  59. return 'Video was not tagged with any alt text.';
  60. },
  61. playOrPause(e) {
  62. let el = e.target;
  63. if(el.getAttribute('playing') == 1) {
  64. el.removeAttribute('playing');
  65. el.pause();
  66. } else {
  67. el.setAttribute('playing', 1);
  68. el.play();
  69. }
  70. },
  71. toggleContentWarning(status) {
  72. this.$emit('togglecw');
  73. }
  74. }
  75. }
  76. </script>