VideoPresenter.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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" :poster="poster()">
  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. poster() {
  75. let url = this.status.media_attachments[0].preview_url;
  76. if(url.endsWith('no-preview.jpg') || url.endsWith('no-preview.png')) {
  77. return;
  78. }
  79. return url;
  80. }
  81. }
  82. }
  83. </script>