檢查圖片,視頻格式

感謝提供圖片的網站     https://blog.csdn.net/qq_36120342/article/details/87437581

	// 判斷一個url是否可以訪問
	function IsLoad(url, fun) {
		$.ajax({
			url: url,
			type: 'Post',
			success: function(response) {
				if ($.isFunction(fun)) {
					fun(true);
				}
			},
			error: function() {
				if ($.isFunction(fun)) {
					fun(false);
				}
			}
		});
	}
import IsLoad from "../../common/checkImg"

	IsLoad(that.attr, function(res) {
											if (!res) {
												that.attr = '../../static/me/[email protected]'
											}
											// alert('請求的url可以訪問');
										})

檢查視頻的地址

<view class="" v-if="urlVideo!=''">
				<video :src="urlVideo" controls autoplay="true"></video>
			</view>



<script>

import checkMPUrl from '../../../common/checkmp4.js'


onload:方法

			if (that.content.indexOf('video') !== -1) {
				if (that.content.indexOf('.mp4') !== -1)
					this.urlVideo = that.content.substring(that.content.indexOf('src') + 5, that.content.indexOf('mp4') + 3)
					// this.urlVideo ='http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400'

				console.log("視頻地址:", urlVideo)
				if (checkMPUrl(this.urlVideo) != 200) {
					uni.showToast({
						title: "該視屏無法播放",
						icon: 'none'
					})
				}
			} else {
				this.urlVideo = "";
			}


style:
.video {
		height: 200px;
		flex: 1;
	}
function CheckStatus(url){
    $.ajax({
        type: "GET",
        cache: false,
        url: url,
        dataType: "jsonp", //跨域採用jsonp方式
        processData: false,
        data: "",
        complete: function (data) {
            if (data.status==200) {
                console.log("成功");
            } else {
                console.log("失敗");
            }

        }
    });
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章