video.js 671 B

12345678910111213141516171819202122232425262728
  1. export default {
  2. template: `<video :controls="controls" :autoplay="autoplay" :muted="muted" :src="computed_src" />`,
  3. props: {
  4. controls: Boolean,
  5. autoplay: Boolean,
  6. muted: Boolean,
  7. src: String,
  8. },
  9. data: function () {
  10. return {
  11. computed_src: undefined,
  12. };
  13. },
  14. mounted() {
  15. setTimeout(() => this.compute_src(), 0); // NOTE: wait for window.path_prefix to be set in app.mounted()
  16. },
  17. updated() {
  18. this.compute_src();
  19. },
  20. methods: {
  21. compute_src() {
  22. this.computed_src = (this.src.startsWith("/") ? window.path_prefix : "") + this.src;
  23. },
  24. seek(seconds) {
  25. this.$el.currentTime = seconds;
  26. },
  27. },
  28. };