Procházet zdrojové kódy

使用ws-flv方式拉流

kkkkk před 5 roky
rodič
revize
e682bd6607
4 změnil soubory, kde provedl 32 přidání a 7 odebrání
  1. 2 2
      global.js
  2. 2 1
      public/video/video.html
  3. 0 1
      src/components/control.vue
  4. 28 3
      src/components/videoList.vue

+ 2 - 2
global.js

@@ -1,6 +1,6 @@
-const host = 'http://localhost:801/index/api';
+const host = 'http://localhost/index/api';
 const secret = '035c73f7-bb6b-4889-a715-d9eb2d1925cc';
-const baseMediaUrl='rtmp://localhost/';
+const baseMediaUrl='ws://localhost/';
 function genApiUrl(method){
 	return host+method+"?secret="+secret;
 }

+ 2 - 1
public/video/video.html

@@ -25,7 +25,8 @@
 		</script>
 	</head>
 	<body>
-		<live-player id="player01" live="true" stretch="true" show-custom-button="false"></live-player>
+		<live-player id="player01" live="true" stretch="true" show-custom-button="false">
+		</live-player>
 		<script>
 			var videoPath=getQueryVariable("url");
 			console.log('播放地址:'+videoPath);

+ 0 - 1
src/components/control.vue

@@ -25,7 +25,6 @@
 			<el-table-column prop="peer_ip" label="远端"></el-table-column>
 			<el-table-column prop="local_ip" label="本地"></el-table-column>
 			<el-table-column prop="typeid" label="类型"></el-table-column>
-
 			<el-table-column align="right">
 				<template slot="header" slot-scope="scope">
 					<el-button icon="el-icon-refresh-right" circle @click="getAllSession()"></el-button>

+ 28 - 3
src/components/videoList.vue

@@ -27,7 +27,10 @@
 				scrolling="no"
 				allowtransparency="yes"
 			></iframe>
-			<div id="shared">
+			<div id="shared" style="text-align: right;">
+				<div style="margin-bottom: 0.5rem;">
+					<el-button type="primary" size="small" @click="startRecord()">录制</el-button>
+				</div>
 				<div style="display: flex; margin-bottom: 0.5rem; height: 2.5rem;">
 					<span style="width: 5rem; line-height: 2.5rem; text-align: right;">播放地址:</span>
 					<el-input v-model="getPlayerShared.sharedUrl" :disabled="true" v-on:click.native="copySharedInfo(getPlayerShared.sharedUrl)"></el-input>
@@ -90,7 +93,6 @@ export default {
 				method: 'get',
 				url: this.$global.genApiUrl('/getMediaList') + '&schema=rtmp'
 			}).then(function(res) {
-				console.log(JSON.stringify(res.data));
 				if (res.data.code == 0) {
 					that.videoList = res.data.data;
 				}
@@ -104,7 +106,7 @@ export default {
 		},
 		showVideo: function(streamInfo) {
 			this.showVideoDialog = true;
-			this.videoUrl = this.$global.baseMediaUrl + streamInfo.app + '/' + streamInfo.stream;
+			this.videoUrl = this.$global.baseMediaUrl + streamInfo.app + '/' + streamInfo.stream+".flv";
 			this.currentPlayerInfo = streamInfo;
 		},
 		copySharedInfo: function(data) {
@@ -126,6 +128,29 @@ export default {
 					});
 				}
 			);
+		},
+		startRecord:function(){
+			let that = this;
+			let streamInfo=this.currentPlayerInfo;
+			this.$axios({
+				method: 'get',
+				url: this.$global.genApiUrl('/startRecord') + '&type=0&vhost='+streamInfo.vhost+"&app="+streamInfo.app+"&stream="+streamInfo.stream+"&wait_for_record=1&continue_record=1&customized_path='/home/kkkkk/Documents/ZLMediaKit/release/linux/Debug'"
+			}).then(function(res) {
+				console.log(JSON.stringify(res.data));
+				if (res.data.code == 0&&res.data.result) {
+					that.$message({
+						showClose: true,
+						message: '开始录制',
+						type: 'success'
+					});
+				}else{
+					that.$message({
+						showClose: true,
+						message: res.data.msg,
+						type: 'error'
+					});
+				}
+			});
 		}
 	}
 };