国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

Vue 瑩石攝像頭直播視頻實例代碼

2024-05-06 15:30:52
字體:
來源:轉載
供稿:網友

Vue 瑩石攝像頭直播視頻代碼。

HTML代碼:

<div class="mainClass" v-show="rtmp_url!=''"> <video id="myPlayer" controls playsinline webkit-playsinline autoplay>  <source type="application/x-mpegURL" :src="http_url"/>  <source :src="rtmp_url"/> </video>   </div>

直播地址是調用接口獲取的。

<script>export default {  data(){   return{    player:"",    rtmp_url:"",    http_url:"",    message:'加載中...',   }  },  mounted(){    this.GetLiveUrl();  },  methods:{   GetLiveUrl(){    //異步獲取直播地址,并賦值給rtmp_url,http_url   }  },  updated() {   if(this.rtmp_url!=""){    //如果在mounted中聲明,直播地址還未取到,導致視頻不顯示。所以放在了這里    this.player = new EZUIPlayer('myPlayer');    }  }}</script>

補充:vue H5項目調用手機攝像頭錄像并上傳

<!DOCTYPE html><html><head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>上傳文件</title> <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script> <script src="https://unpkg.com/axios/dist/axios.min.js"></script> <style>  input.file   {   position: relative;   -moz-opacity:0 ;   filter:alpha(opacity: 0);   opacity: 0;   z-index: 2;  }   .wrapper{   color: #fff;   background-color: #31b0d5;   border-color: #269abc;   margin-top: 5px;   margin-bottom: 5px;   display: inline-block;   padding: 6px 12px;   margin-bottom: 0;   font-size: 14px;   font-weight: 400;   line-height: 1.42857143;   text-align: center;   white-space: nowrap;   vertical-align: middle;   -ms-touch-action: manipulation;   touch-action: manipulation;   cursor: pointer;   -webkit-user-select: none;   -moz-user-select: none;   -ms-user-select: none;   user-select: none;   background-image: none;   border: 1px solid transparent;   border-radius: 4px;  } </style></head><body> <div id="app" v-cloak>  <h4>上傳視頻demo</h4>  <div>   <span type="primary" class="wrapper">    <label class="btn" for="fileUpload">上傳視頻demo</label>   </span>   <input type="file" accept="video/*" id="fileUpload" style="position:absolute; clip:rect(0 0 0 0);" @change="uploadVideo($event)">  </div> </div> <script> var app = new Vue({  el: '#app',  data: {  },  methods: {   uploadVideo(e) {    //e.target.value文件名    var file = e.target.files[0];    var formdata = new FormData();    formdata.append('fileStream', file);    console.log('正在上傳視頻...')    this.doUpload(formdata);   },   doUpload(formdata) {    axios.post('/teacher/doUpload', formdata).then(res => {     if (res.data.success) {      console.log('上傳成功');     } else {      console.log('上傳失敗');     }    }).catch(err => {     console.log(err);    })   }  } }); </script></body></html>            
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 斗六市| 静乐县| 弋阳县| 武胜县| 凤冈县| 大田县| 石台县| 普宁市| 阿拉善左旗| 正定县| 奉贤区| 嘉善县| 大新县| 新田县| 利川市| 东乡县| 霍山县| 遂溪县| 方城县| 临澧县| 通许县| 巴青县| 闽清县| 理塘县| 龙江县| 江口县| 富民县| 西城区| 台州市| 孝感市| 西和县| 大埔区| 称多县| 河源市| 武宣县| 麻城市| 益阳市| 喜德县| 康平县| 利辛县| 桐乡市|