视频的页面展示(前端vue+后端springboot)

本文介绍了如何使用Vue.js前端框架与SpringBoot后端框架结合,实现视频页面的展示和交互功能。通过讲解关键技术和步骤,帮助读者理解前后端协作在视频项目中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 <div v-for="item in videoData" :key="item.kshv_id" 
 :id="item.kshv_id" v-loading="loading"> //循环遍历后端过来的数据为videoData

data声明为videoData:[],

获取请求后赋值
this.videoData = res.data.info.list;
this.videoSRC(res.data.info.list);
videoSRC(list){
   for(var i=0;i<list.length;i++){
       this.videoAjax(list[i]);
   }  
 },
videoAjax(item){
    
            axios.post(xxx'/xxx', 
                {
                    传参
                },{
                responseType: 'blob'
                },{
                // 单独配置
                withCredentials: true
                }).then((res)=>{
                    var html = "<video autoplay='true' height='100%' width='100%' controls='controls' loop='true' src='"+window.URL.createObjectURL(new Blob([res.data]))+"' ></video> ";
                    document.getElementById(item.kshv_id).innerHTML = html;
                    this.loading = false;
                }).catch(function (response) {
                     console.log(response);
                });
        },
后端
import org.apache.commons.io.FileUtils;
@PostMapping("/xxx")
    public ResponseEntity<byte[]> previewVideoONE(@RequestBody Map<String,Object> map, HttpServletResponse response) throws Exception {
        
        String token = (String) mapa.get("token");
        //System.out.println("=====================url================"+mapa.get("url").toString());
        try {
            ResponseEntity<byte[]> responseEntity = null;
            Map<String,Object> mp = new HashMap<>();
            String path = mapa.get("url").toString();
//            System.out.println("============last============"+path.substring(path.lastIndexOf("//") + 1));
            HttpHeaders headers = new HttpHeaders();
            headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
            headers.setContentDispositionFormData("attachment", path);
//          headers.setContentDispositionFormData("attachment", path.substring(path.lastIndexOf("//") + 1));
            responseEntity = new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(new File(path)), headers, HttpStatus.CREATED);
            return responseEntity;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }


url字段处理
map.get("video_url").toString().replace("\\","//")+"'

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值