oss上传视频

mui('#onevideo').on('change', '.upvideo', function() {
		console.log('点击上传视频按钮了');
		var file = this.files[0];
		console.log(file)
		if(file.type != 'video/mp4') {
			mui.toast("文件必须为MP4格式");
			this.outerHTML = this.outerHTML;
			return false;
		} 

		//	视频大小最大10MB
		if(file.size / 1024 / 1024 > 10) {
			mui.toast('视频大小不能超过10MB')
			return false;
		}

		//	读取视频对象url,为了获取视频的时间
		var prevideo = window.URL.createObjectURL(file);
		console.log(prevideo);
		document.getElementById("newVideo").src = prevideo;

		//	视频最长10秒
		waitingShow();
		setTimeout(function() {
			waitingHide();
			var vediotime = document.getElementById("newVideo").duration;
			console.log(vediotime)
			if(vediotime <= 10) {
				uploadVideo(file, prevideo);
			} else {
				mui.toast('视频长度不能超过10秒');
				return false;
			}

		}, 3000);

	});

  

posted @ 2017-08-02 19:34  RAINHAN  阅读(1120)  评论(0编辑  收藏  举报