当前位置:   article > 正文

nginx部署视频服务(视频下载链接也ok),vue前端如何播放视频

nginx部署视频服务(视频下载链接也ok),vue前端如何播放视频

浏览器点击链接就出现播放,我想利用前端vue,让其播放视频,怎么做?

  1. //播放视频
  2. viewVideo(row, type) {
  3. console.log("row=", row);
  4. console.log("totalBatch=", row.totalBatch, "idNumber", row.idNumber, "batchName=", row.batchName);
  5. let videoName = row.batchName + "_" + row.idNumber + "_" + type;
  6. let videoUrl = row.totalBatch + "/" + videoName + ".mp4";
  7. let url = "http://192.168.16.119:82/" + videoUrl;
  8. url = "http://192.168.16.119:82/1765267861926932482/10_511181200207095213_3.mp4"
  9. // 在新标签页中打开视频
  10. let newTab = window.open();
  11. newTab.document.write(`
  12. <html>
  13. <head>
  14. <style>
  15. body, html {
  16. margin: 0;
  17. padding: 0;
  18. height: 100%;
  19. display: flex;
  20. justify-content: center;
  21. align-items: center;
  22. background: #000; /* 设置背景色为黑色 */
  23. }
  24. video {
  25. width: auto;
  26. height: 100vh; /* 设置视频高度为整个屏幕的高度 */
  27. display: block;
  28. }
  29. </style>
  30. </head>
  31. <body>
  32. <video controls autoplay>
  33. <source src="${url}" type="video/mp4">
  34. Your browser does not support the video tag.
  35. </video>
  36. </body>
  37. </html>
  38. `);

另外附带nginx的配置

  1. #user nobody;
  2. worker_processes 1;
  3. #error_log logs/error.log;
  4. #error_log logs/error.log notice;
  5. #error_log logs/error.log info;
  6. #pid logs/nginx.pid;
  7. events {
  8. worker_connections 1024;
  9. }
  10. # HTTP模块配置段
  11. http {
  12. # 防DDoS配置
  13. limit_req_zone $binary_remote_addr zone=ddos:10m rate=10r/s;
  14. # 日志配置
  15. access_log /var/log/nginx/access.log;
  16. server {
  17. listen 8090;
  18. server_name 192.168.16.119;
  19. location / {
  20. root html;
  21. index index.html index.htm;
  22. }
  23. error_page 500 502 503 504 /50x.html;
  24. location = /50x.html {
  25. root html;
  26. }
  27. }
  28. # 设置服务器块
  29. server {
  30. listen 82;
  31. server_name 192.168.16.119;
  32. charset utf-8,gbk;
  33. root /home/nginx/www/images/; # 你的文件目录
  34. # 显示目录,默认不开启
  35. autoindex on;
  36. # 显示文件大小
  37. # 显示文件修改时间
  38. autoindex_localtime on;
  39. location ~ \.mp4$ {
  40. mp4; # 支持mp4
  41. mp4_buffer_size 1m;
  42. mp4_max_buffer_size 10m;
  43. }
  44. }
  45. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Monodyee/article/detail/337644
推荐阅读
相关标签
  

闽ICP备14008679号