|
|
|
|
@ -1,22 +1,17 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
|
|
import 'package:dio/dio.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_screenutil/screen_util.dart';
|
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
|
import 'package:http/http.dart' as my_http;
|
|
|
|
|
import 'package:hyzp_ybqx511528_xingwen/components/doJSON.dart';
|
|
|
|
|
import 'package:hyzp_ybqx511528_xingwen/services/EventBus.dart';
|
|
|
|
|
import 'package:hyzp_ybqx511528_xingwen/widget/my_superplayer.dart';
|
|
|
|
|
import 'package:sprintf/sprintf.dart';
|
|
|
|
|
import 'package:hyzp_ybqx511505_sanjiang_new_area_launche/components/doJSON.dart';
|
|
|
|
|
import 'package:hyzp_ybqx511505_sanjiang_new_area_launche/services/EventBus.dart';
|
|
|
|
|
import 'package:hyzp_ybqx511505_sanjiang_new_area_launche/widget/my_superplayer.dart';
|
|
|
|
|
|
|
|
|
|
import '../components/hyxx_data_handle.dart';
|
|
|
|
|
import '../config/service_url.dart';
|
|
|
|
|
import '../res/listContacts.dart';
|
|
|
|
|
import '../widget/my_delay_toast.dart';
|
|
|
|
|
// import 'package:hyzp_ybqx511505_sanjiang_new_area_launche/widget/player_pro.dart';
|
|
|
|
|
// import 'package:hyzp_ybqx511505_sanjiang_new_area_launche/widget/player_pro_new.dart';
|
|
|
|
|
// import 'package:hyzp_ybqx511528_xingwen/widget/player_pro.dart';
|
|
|
|
|
// import 'package:hyzp_ybqx511528_xingwen/widget/player_pro_new.dart';
|
|
|
|
|
import 'UserAuthority.dart';
|
|
|
|
|
import 'commonFun.dart';
|
|
|
|
|
|
|
|
|
|
@ -2007,168 +2002,168 @@ Future getDwspUrlNew(
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
///得到点位视频(Dwsp)播放地址,用插件 http: ^0.12.2
|
|
|
|
|
Future getDwspUrl({@required int index, String theSbgllx = 'dwsp', BuildContext context}) async {
|
|
|
|
|
print('\n --- getingDwVideo = $getingDwVideo --- \n');
|
|
|
|
|
//正在获取点位视频标志,禁止重入
|
|
|
|
|
if (getingDwVideo) {
|
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
|
msg: '正在后台获取 $getingDwmc 点位视频地址,请稍后重试',
|
|
|
|
|
toastLength: Toast.LENGTH_SHORT,
|
|
|
|
|
gravity: ToastGravity.CENTER,
|
|
|
|
|
);
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//标注正在获取点位视频的记录
|
|
|
|
|
getingIndex = index;
|
|
|
|
|
print('_getingIndex = $getingIndex');
|
|
|
|
|
eventBus.fire(DwspUpdateEvent('点位视频信息数据更新广播'));
|
|
|
|
|
|
|
|
|
|
getingDwVideo = true;
|
|
|
|
|
getingDwmc = '${(index + 1)}、${listDwinfoGetList2[index]['dwmc']}'; //正在获取视频的点位名称
|
|
|
|
|
print('\n --- 正在后台获取 $getingDwmc 点位视频地址 --- \n');
|
|
|
|
|
print('\n --- getingDwVideo = $getingDwVideo --- \n');
|
|
|
|
|
|
|
|
|
|
String _dwspUrl;
|
|
|
|
|
getCount = 1;
|
|
|
|
|
|
|
|
|
|
//MediaQueryData.fromWindow(window).padding.top //这个就是状态栏的高度
|
|
|
|
|
//ScreenUtil().statusBarHeight //状态栏高度 刘海屏会更高 单位dp
|
|
|
|
|
print('ScreenUtil().statusBarHeight = ${ScreenUtil().statusBarHeight}');
|
|
|
|
|
getSumTime = getCurrentTiem();
|
|
|
|
|
MyDelayToast(
|
|
|
|
|
context: context,
|
|
|
|
|
showTime: 30,
|
|
|
|
|
top: ScreenUtil().statusBarHeight + 2.5,
|
|
|
|
|
left: ScreenUtil().screenWidth - 80 - 2.5);
|
|
|
|
|
|
|
|
|
|
print('开始第$getCount次获取视频地址');
|
|
|
|
|
getDwspUrl2(index: index, theSbgllx: theSbgllx).then((url) {
|
|
|
|
|
_dwspUrl = url;
|
|
|
|
|
if (!isVideoUrl(_dwspUrl)) {
|
|
|
|
|
print('第$getCount次获取视频地址失败,等待1秒后重试');
|
|
|
|
|
getCount++;
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () async {
|
|
|
|
|
print('开始第$getCount次获取视频地址');
|
|
|
|
|
getDwspUrl2(index: index, theSbgllx: theSbgllx).then((url) {
|
|
|
|
|
_dwspUrl = url;
|
|
|
|
|
if (!isVideoUrl(_dwspUrl)) {
|
|
|
|
|
print('第$getCount次获取视频地址失败,等待1秒后重试');
|
|
|
|
|
getCount++;
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () async {
|
|
|
|
|
print('开始第$getCount次获取视频地址');
|
|
|
|
|
getDwspUrl2(index: index, theSbgllx: theSbgllx).then((url) {
|
|
|
|
|
_dwspUrl = url;
|
|
|
|
|
if (!isVideoUrl(_dwspUrl)) {
|
|
|
|
|
print('第$getCount次获取视频地址失败,等待1秒后重试');
|
|
|
|
|
getCount++;
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () async {
|
|
|
|
|
print('开始第$getCount次获取视频地址');
|
|
|
|
|
getDwspUrl2(index: index, theSbgllx: theSbgllx).then((url) {
|
|
|
|
|
_dwspUrl = url;
|
|
|
|
|
if (!isVideoUrl(_dwspUrl)) {
|
|
|
|
|
print('第$getCount次获取视频地址失败,等待1秒后重试');
|
|
|
|
|
getCount++;
|
|
|
|
|
Future.delayed(Duration(seconds: 1), () async {
|
|
|
|
|
print('开始第$getCount次获取视频地址');
|
|
|
|
|
getDwspUrl2(index: index, theSbgllx: theSbgllx).then((url) {
|
|
|
|
|
_dwspUrl = url;
|
|
|
|
|
if (!isVideoUrl(_dwspUrl)) {
|
|
|
|
|
getSumTime = getCurrentTiem() - getSumTime;
|
|
|
|
|
print('第$getCount次获取 $getingDwmc 点位视频地址失败,直接返回。共用时 $getSumTime 秒');
|
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
|
msg: '第$getCount次获取 $getingDwmc 点位视频地址失败,请稍后重试。共用时 $getSumTime 秒',
|
|
|
|
|
toastLength: Toast.LENGTH_SHORT,
|
|
|
|
|
gravity: ToastGravity.CENTER,
|
|
|
|
|
);
|
|
|
|
|
//正在获取点位视频标志,禁止重入
|
|
|
|
|
getingDwVideo = false;
|
|
|
|
|
|
|
|
|
|
//标注正在获取点位视频的记录
|
|
|
|
|
getingIndex = -1;
|
|
|
|
|
print('_getingIndex = $getingIndex');
|
|
|
|
|
eventBus.fire(DwspUpdateEvent('点位视频信息数据更新广播'));
|
|
|
|
|
} else {
|
|
|
|
|
print('开始播放:第$getCount次成功获取的视频地址');
|
|
|
|
|
playUrl(index: index, url: _dwspUrl, context: context);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
print('开始播放:第$getCount次成功获取的视频地址');
|
|
|
|
|
playUrl(index: index, url: _dwspUrl, context: context);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
print('开始播放:第$getCount次成功获取的视频地址');
|
|
|
|
|
playUrl(index: index, url: _dwspUrl, context: context);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
print('开始播放:第$getCount次成功获取的视频地址');
|
|
|
|
|
playUrl(index: index, url: _dwspUrl, context: context);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
print('开始播放:第$getCount次成功获取的视频地址');
|
|
|
|
|
playUrl(index: index, url: _dwspUrl, context: context);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//不能放到此处,此处不会等待,将导致禁止重入失败
|
|
|
|
|
//正在获取点位视频标志,禁止重入
|
|
|
|
|
//getingDwVideo = false;
|
|
|
|
|
|
|
|
|
|
//print('失败:$getCount次获取的视频地址都失败!');
|
|
|
|
|
return _dwspUrl;
|
|
|
|
|
}
|
|
|
|
|
// Future getDwspUrl({@required int index, String theSbgllx = 'dwsp', BuildContext context}) async {
|
|
|
|
|
// print('\n --- getingDwVideo = $getingDwVideo --- \n');
|
|
|
|
|
// //正在获取点位视频标志,禁止重入
|
|
|
|
|
// if (getingDwVideo) {
|
|
|
|
|
// Fluttertoast.showToast(
|
|
|
|
|
// msg: '正在后台获取 $getingDwmc 点位视频地址,请稍后重试',
|
|
|
|
|
// toastLength: Toast.LENGTH_SHORT,
|
|
|
|
|
// gravity: ToastGravity.CENTER,
|
|
|
|
|
// );
|
|
|
|
|
// return '';
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// //标注正在获取点位视频的记录
|
|
|
|
|
// getingIndex = index;
|
|
|
|
|
// print('_getingIndex = $getingIndex');
|
|
|
|
|
// eventBus.fire(DwspUpdateEvent('点位视频信息数据更新广播'));
|
|
|
|
|
//
|
|
|
|
|
// getingDwVideo = true;
|
|
|
|
|
// getingDwmc = '${(index + 1)}、${listDwinfoGetList2[index]['dwmc']}'; //正在获取视频的点位名称
|
|
|
|
|
// print('\n --- 正在后台获取 $getingDwmc 点位视频地址 --- \n');
|
|
|
|
|
// print('\n --- getingDwVideo = $getingDwVideo --- \n');
|
|
|
|
|
//
|
|
|
|
|
// String _dwspUrl;
|
|
|
|
|
// getCount = 1;
|
|
|
|
|
//
|
|
|
|
|
// //MediaQueryData.fromWindow(window).padding.top //这个就是状态栏的高度
|
|
|
|
|
// //ScreenUtil().statusBarHeight //状态栏高度 刘海屏会更高 单位dp
|
|
|
|
|
// print('ScreenUtil().statusBarHeight = ${ScreenUtil().statusBarHeight}');
|
|
|
|
|
// getSumTime = getCurrentTiem();
|
|
|
|
|
// MyDelayToast(
|
|
|
|
|
// context: context,
|
|
|
|
|
// showTime: 30,
|
|
|
|
|
// top: ScreenUtil().statusBarHeight + 2.5,
|
|
|
|
|
// left: ScreenUtil().screenWidth - 80 - 2.5);
|
|
|
|
|
//
|
|
|
|
|
// print('开始第$getCount次获取视频地址');
|
|
|
|
|
// getDwspUrl2(index: index, theSbgllx: theSbgllx).then((url) {
|
|
|
|
|
// _dwspUrl = url;
|
|
|
|
|
// if (!isVideoUrl(_dwspUrl)) {
|
|
|
|
|
// print('第$getCount次获取视频地址失败,等待1秒后重试');
|
|
|
|
|
// getCount++;
|
|
|
|
|
// Future.delayed(Duration(seconds: 1), () async {
|
|
|
|
|
// print('开始第$getCount次获取视频地址');
|
|
|
|
|
// getDwspUrl2(index: index, theSbgllx: theSbgllx).then((url) {
|
|
|
|
|
// _dwspUrl = url;
|
|
|
|
|
// if (!isVideoUrl(_dwspUrl)) {
|
|
|
|
|
// print('第$getCount次获取视频地址失败,等待1秒后重试');
|
|
|
|
|
// getCount++;
|
|
|
|
|
// Future.delayed(Duration(seconds: 1), () async {
|
|
|
|
|
// print('开始第$getCount次获取视频地址');
|
|
|
|
|
// getDwspUrl2(index: index, theSbgllx: theSbgllx).then((url) {
|
|
|
|
|
// _dwspUrl = url;
|
|
|
|
|
// if (!isVideoUrl(_dwspUrl)) {
|
|
|
|
|
// print('第$getCount次获取视频地址失败,等待1秒后重试');
|
|
|
|
|
// getCount++;
|
|
|
|
|
// Future.delayed(Duration(seconds: 1), () async {
|
|
|
|
|
// print('开始第$getCount次获取视频地址');
|
|
|
|
|
// getDwspUrl2(index: index, theSbgllx: theSbgllx).then((url) {
|
|
|
|
|
// _dwspUrl = url;
|
|
|
|
|
// if (!isVideoUrl(_dwspUrl)) {
|
|
|
|
|
// print('第$getCount次获取视频地址失败,等待1秒后重试');
|
|
|
|
|
// getCount++;
|
|
|
|
|
// Future.delayed(Duration(seconds: 1), () async {
|
|
|
|
|
// print('开始第$getCount次获取视频地址');
|
|
|
|
|
// getDwspUrl2(index: index, theSbgllx: theSbgllx).then((url) {
|
|
|
|
|
// _dwspUrl = url;
|
|
|
|
|
// if (!isVideoUrl(_dwspUrl)) {
|
|
|
|
|
// getSumTime = getCurrentTiem() - getSumTime;
|
|
|
|
|
// print('第$getCount次获取 $getingDwmc 点位视频地址失败,直接返回。共用时 $getSumTime 秒');
|
|
|
|
|
// Fluttertoast.showToast(
|
|
|
|
|
// msg: '第$getCount次获取 $getingDwmc 点位视频地址失败,请稍后重试。共用时 $getSumTime 秒',
|
|
|
|
|
// toastLength: Toast.LENGTH_SHORT,
|
|
|
|
|
// gravity: ToastGravity.CENTER,
|
|
|
|
|
// );
|
|
|
|
|
// //正在获取点位视频标志,禁止重入
|
|
|
|
|
// getingDwVideo = false;
|
|
|
|
|
//
|
|
|
|
|
// //标注正在获取点位视频的记录
|
|
|
|
|
// getingIndex = -1;
|
|
|
|
|
// print('_getingIndex = $getingIndex');
|
|
|
|
|
// eventBus.fire(DwspUpdateEvent('点位视频信息数据更新广播'));
|
|
|
|
|
// } else {
|
|
|
|
|
// print('开始播放:第$getCount次成功获取的视频地址');
|
|
|
|
|
// playUrl(index: index, url: _dwspUrl, context: context);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// print('开始播放:第$getCount次成功获取的视频地址');
|
|
|
|
|
// playUrl(index: index, url: _dwspUrl, context: context);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// print('开始播放:第$getCount次成功获取的视频地址');
|
|
|
|
|
// playUrl(index: index, url: _dwspUrl, context: context);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// print('开始播放:第$getCount次成功获取的视频地址');
|
|
|
|
|
// playUrl(index: index, url: _dwspUrl, context: context);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// print('开始播放:第$getCount次成功获取的视频地址');
|
|
|
|
|
// playUrl(index: index, url: _dwspUrl, context: context);
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
//
|
|
|
|
|
// //不能放到此处,此处不会等待,将导致禁止重入失败
|
|
|
|
|
// //正在获取点位视频标志,禁止重入
|
|
|
|
|
// //getingDwVideo = false;
|
|
|
|
|
//
|
|
|
|
|
// //print('失败:$getCount次获取的视频地址都失败!');
|
|
|
|
|
// return _dwspUrl;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
///得到点位视频(Dwsp)播放地址,用插件 http: ^0.12.2
|
|
|
|
|
Future getDwspUrl2({@required int index, String theSbgllx = 'dwsp'}) async {
|
|
|
|
|
String _dwspUrl = '';
|
|
|
|
|
|
|
|
|
|
print('开始处理 ${mapHyshlx[theSbgllx]['text']} 网络请求...');
|
|
|
|
|
String api = ServicePath.getDwspUrl + '${index.toString()}.php';
|
|
|
|
|
print('api = ${api}');
|
|
|
|
|
//api = http://125.64.218.67:9908/rtmp/1.php
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
my_http.Response response = await my_http.get(api);
|
|
|
|
|
print('response.statusCode = ${response.statusCode}');
|
|
|
|
|
//I/flutter (18114): Response status: 200
|
|
|
|
|
|
|
|
|
|
//var ret = json.decode(response.body); //报错
|
|
|
|
|
//print('Utf8Codec().decode(response.bodyBytes) = ${Utf8Codec().decode(response.bodyBytes)}');
|
|
|
|
|
// I/flutter (18114): rtmp://125.64.218.67:9903/rtp/26CCDAA7
|
|
|
|
|
|
|
|
|
|
print('response = ${response.toString()}');
|
|
|
|
|
//response = Instance of 'Response'
|
|
|
|
|
|
|
|
|
|
if (response.statusCode == 200) {
|
|
|
|
|
//final Map<String, dynamic> responseData = json.decode(response.body);
|
|
|
|
|
//报错:e:Error on line 1, column 18: Invalid media type: expected application/json;
|
|
|
|
|
_dwspUrl = Utf8Codec().decode(response.bodyBytes).replaceAll('\n', ''); //删除所有换行符
|
|
|
|
|
print('_dwspUrl = $_dwspUrl');
|
|
|
|
|
//_dwspUrl = rtmp://125.64.218.67:9903/rtp/30C91573
|
|
|
|
|
} else {
|
|
|
|
|
throw Exception('${mapHyshlx[theSbgllx]['text']} 后端接口出现异常,请检测代码和服务器情况...');
|
|
|
|
|
getingDwVideo = false; //出现异常必须提前释放禁止重入标志
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
print('${mapHyshlx[theSbgllx]['text']} 网络请求过程异常 e:${e}');
|
|
|
|
|
Fluttertoast.showToast(
|
|
|
|
|
msg: 'ERROR:======>${e}',
|
|
|
|
|
toastLength: Toast.LENGTH_SHORT,
|
|
|
|
|
gravity: ToastGravity.CENTER,
|
|
|
|
|
);
|
|
|
|
|
getingDwVideo = false; //出现异常必须提前释放禁止重入标志
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _dwspUrl;
|
|
|
|
|
}
|
|
|
|
|
// Future getDwspUrl2({@required int index, String theSbgllx = 'dwsp'}) async {
|
|
|
|
|
// String _dwspUrl = '';
|
|
|
|
|
//
|
|
|
|
|
// print('开始处理 ${mapHyshlx[theSbgllx]['text']} 网络请求...');
|
|
|
|
|
// String api = ServicePath.getDwspUrl + '${index.toString()}.php';
|
|
|
|
|
// print('api = ${api}');
|
|
|
|
|
// //api = http://125.64.218.67:9908/rtmp/1.php
|
|
|
|
|
//
|
|
|
|
|
// try {
|
|
|
|
|
// my_http.Response response = await my_http.get(api);
|
|
|
|
|
// print('response.statusCode = ${response.statusCode}');
|
|
|
|
|
// //I/flutter (18114): Response status: 200
|
|
|
|
|
//
|
|
|
|
|
// //var ret = json.decode(response.body); //报错
|
|
|
|
|
// //print('Utf8Codec().decode(response.bodyBytes) = ${Utf8Codec().decode(response.bodyBytes)}');
|
|
|
|
|
// // I/flutter (18114): rtmp://125.64.218.67:9903/rtp/26CCDAA7
|
|
|
|
|
//
|
|
|
|
|
// print('response = ${response.toString()}');
|
|
|
|
|
// //response = Instance of 'Response'
|
|
|
|
|
//
|
|
|
|
|
// if (response.statusCode == 200) {
|
|
|
|
|
// //final Map<String, dynamic> responseData = json.decode(response.body);
|
|
|
|
|
// //报错:e:Error on line 1, column 18: Invalid media type: expected application/json;
|
|
|
|
|
// _dwspUrl = Utf8Codec().decode(response.bodyBytes).replaceAll('\n', ''); //删除所有换行符
|
|
|
|
|
// print('_dwspUrl = $_dwspUrl');
|
|
|
|
|
// //_dwspUrl = rtmp://125.64.218.67:9903/rtp/30C91573
|
|
|
|
|
// } else {
|
|
|
|
|
// throw Exception('${mapHyshlx[theSbgllx]['text']} 后端接口出现异常,请检测代码和服务器情况...');
|
|
|
|
|
// getingDwVideo = false; //出现异常必须提前释放禁止重入标志
|
|
|
|
|
// }
|
|
|
|
|
// } catch (e) {
|
|
|
|
|
// print('${mapHyshlx[theSbgllx]['text']} 网络请求过程异常 e:${e}');
|
|
|
|
|
// Fluttertoast.showToast(
|
|
|
|
|
// msg: 'ERROR:======>${e}',
|
|
|
|
|
// toastLength: Toast.LENGTH_SHORT,
|
|
|
|
|
// gravity: ToastGravity.CENTER,
|
|
|
|
|
// );
|
|
|
|
|
// getingDwVideo = false; //出现异常必须提前释放禁止重入标志
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// return _dwspUrl;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/// 获取最新版本号
|
|
|
|
|
Future getNewverUrl() async {
|
|
|
|
|
|