Skip to content

Commit

Permalink
202206040616
Browse files Browse the repository at this point in the history
  • Loading branch information
ersonw committed Jun 3, 2022
1 parent 4aee576 commit 85d5674
Show file tree
Hide file tree
Showing 40 changed files with 1,466 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .dart_tool/package_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@
"languageVersion": "2.15"
}
],
"generated": "2022-06-02T20:45:01.161959Z",
"generated": "2022-06-03T16:30:27.507661Z",
"generator": "pub",
"generatorVersion": "2.15.1"
}
2 changes: 1 addition & 1 deletion .flutter-plugins-dependencies

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion .idea/libraries/Flutter_Plugins.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 33 additions & 15 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .packages
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# For more info see: https://dart.dev/go/dot-packages-deprecation
#
# Generated by pub on 2022-06-03 04:45:01.144668.
# Generated by pub on 2022-06-04 00:30:27.483097.
args:file:///Users/admin/flutter/.pub-cache/hosted/pub.dartlang.org/args-2.3.0/lib/
asn1lib:file:///Users/admin/flutter/.pub-cache/hosted/pub.dartlang.org/asn1lib-1.1.0/lib/
async:file:///Users/admin/flutter/.pub-cache/hosted/pub.dartlang.org/async-2.8.2/lib/
Expand Down
Binary file modified android/.gradle/6.7/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified android/.gradle/6.7/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified android/.gradle/6.7/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified android/.gradle/6.7/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified android/.gradle/6.7/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified android/.gradle/6.7/javaCompile/classAnalysis.bin
Binary file not shown.
Binary file modified android/.gradle/6.7/javaCompile/jarAnalysis.bin
Binary file not shown.
Binary file modified android/.gradle/6.7/javaCompile/javaCompile.lock
Binary file not shown.
Binary file modified android/.gradle/6.7/javaCompile/taskHistory.bin
Binary file not shown.
Binary file modified android/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified android/.gradle/buildOutputCleanup/outputFiles.bin
Binary file not shown.
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<application
android:label="movie2"
android:name="${applicationName}"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
Expand Down
12 changes: 11 additions & 1 deletion android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,15 @@
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<!--网络权限-->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!--点播播放器悬浮窗权限-->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<!--存储-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
Binary file added assets/icons/downloadIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/shareIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/starIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/zanActiveIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/icons/zanIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
6 changes: 6 additions & 0 deletions lib/AssetsIcon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,11 @@ class AssetsIcon {
static const String searchTag = ('assets/icons/searchTag.png');
static const String VIPIcon = ('assets/icons/VIPIcon.png');
static const String clearIcon = ('assets/icons/clearIcon.png');

static const String zanActiveIcon = ('assets/icons/zanActiveIcon.png');
static const String zanIcon = ('assets/icons/zanIcon.png');
static const String downloadIcon = ('assets/icons/downloadIcon.png');
static const String shareIcon = ('assets/icons/shareIcon.png');
static const String starIcon = ('assets/icons/starIcon.png');

}
20 changes: 15 additions & 5 deletions lib/Global.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'dart:convert';
import 'dart:math';
import 'dart:typed_data';
import 'package:device_info/device_info.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -44,7 +46,6 @@ class Global {
static Profile profile = Profile();
static bool initMain = false;
static const String mykey = 'e797e49a5f21d99840c3a07dee2c3c7c';
static const String myiv = 'e797e49a5f21d99840c3a07dee2c3c7a';

static String? deviceId;
static String? platform;
Expand Down Expand Up @@ -198,15 +199,24 @@ class Global {
// }
static String encryptCode(String text){
final key = XYQ.Key.fromUtf8(mykey);
final iv = XYQ.IV.fromUtf8(myiv);
// final iv = XYQ.IV.fromUtf8(myiv);
final iv = XYQ.IV.fromSecureRandom(128);
final encrypter = XYQ.Encrypter(XYQ.AES(key, mode: XYQ.AESMode.ecb));
final encrypted = encrypter.encrypt(text, iv: iv);
return encrypted.base64;
return '$mykey#${encrypted.base64}';
}
static String decryptCode(String text){
String? ikey;
if(text.contains('#')) {
ikey = text.substring(0, text.indexOf('#'));
// print(ikey);
text = text.substring(text.indexOf('#')+1);
// print(text);
}
final encrypted = XYQ.Encrypted.fromBase64(text);
final key = XYQ.Key.fromUtf8(mykey);
final iv = XYQ.IV.fromUtf8(myiv);
final key = XYQ.Key.fromUtf8(ikey ?? mykey);
// final iv = XYQ.IV.fromUtf8(myiv);
final iv = XYQ.IV.fromSecureRandom(128);
final encrypter = XYQ.Encrypter(XYQ.AES(key, mode: XYQ.AESMode.ecb));
return encrypter.decrypt(encrypted, iv: iv);
}
Expand Down
125 changes: 124 additions & 1 deletion lib/Page/PlayerPage.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:movie2/Module/GeneralRefresh.dart';
import 'package:movie2/data/Player.dart';
import 'package:movie2/tools/Request.dart';
import 'package:movie2/tools/VideoPlayerUtils.dart';
import 'package:movie2/tools/widget/LockIcon.dart';
import 'package:movie2/tools/widget/VideoPlayerBottom.dart';
import 'package:movie2/tools/widget/VideoPlayerGestures.dart';
import 'package:movie2/tools/widget/VideoPlayerTop.dart';
import '../tools/TempValue.dart';
import 'dart:ui';
import '../Global.dart';

class PlayerPage extends StatefulWidget {
int id;
Expand All @@ -8,8 +20,119 @@ class PlayerPage extends StatefulWidget {
_PlayerPage createState() => _PlayerPage();
}
class _PlayerPage extends State<PlayerPage>{
// 是否全屏
bool get _isFullScreen => MediaQuery.of(context).orientation == Orientation.landscape;
Size get _window => MediaQueryData.fromWindow(window).size;
double get _width => _isFullScreen ? _window.width : _window.width;
double get _height => _isFullScreen ? _window.height : _window.width*9/16;
Widget? _playerUI;
VideoPlayerTop? _top;
VideoPlayerBottom? _bottom;
LockIcon? _lockIcon; // 控制是否沉浸式的widget


final ScrollController _controller = ScrollController();
bool refresh = true;
// Widget? _playerUI;
Player player = Player();
@override
void initState() {
getPlayer();
super.initState();
}
getPlayer()async{
Map<String, dynamic> map = await Request.videoPlayer(widget.id);
setState(() {
refresh = false;
});
if(map['error'] != null){
if(map['error'] == 'login') Global.loginPage().then((value) => getPlayer());
return;
}
if(map['player'] != null){
setState(() {
player = Player.formJson(map['player']);
});
// print(player.vodPlayUrl);
VideoPlayerUtils.playerHandle(player.vodPlayUrl!);
// 播放新视频,初始化监听
VideoPlayerUtils.initializedListener(key: this, listener: (initialize,widget){
if(initialize){ // 初始化成功后,更新UI
_top ??= VideoPlayerTop(title: player.title,);
_lockIcon ??= LockIcon(lockCallback: (){
_top!.opacityCallback(!TempValue.isLocked);
_bottom!.opacityCallback(!TempValue.isLocked);
},);
_bottom ??= VideoPlayerBottom();
_playerUI = widget;
if(!mounted) return;
setState(() {});
}
});
}
}
@override
Widget build(BuildContext context) {
return Container();
return GeneralRefresh(controller: _controller, onRefresh: (){
setState(() {
refresh = true;
});
getPlayer();
}, body: _isFullScreen ? safeAreaPlayerUI() : Column(
children: [
safeAreaPlayerUI(),
// const SizedBox(height: 100,),
// InkWell(
// // 切换视频
// onTap: () {},
// child: Container(
// alignment: Alignment.center,
// width: 120, height: 60,
// color: Colors.orangeAccent,
// child: const Text("切换视频",style: TextStyle(fontSize: 18),),
// ),
// )
],
), refresh: refresh);
}
Widget safeAreaPlayerUI(){
return SafeArea( // 全屏的安全区域
top: !_isFullScreen,
bottom: !_isFullScreen,
left: !_isFullScreen,
right: !_isFullScreen,
child: SizedBox(
height: _height,
width: _width,
child: _playerUI != null ? VideoPlayerGestures(
appearCallback: (appear){
_top!.opacityCallback(appear);
_lockIcon!.opacityCallback(appear);
_bottom!.opacityCallback(appear);
},
children: [
Center(
child: _playerUI,
),
_isFullScreen ? _top! : Container(),
_lockIcon!,
_bottom!
],
) : Container(
alignment: Alignment.center,
color: Colors.black26,
child: const CircularProgressIndicator(
strokeWidth: 3,
),
)
),
);
}
@override
void dispose() {
VideoPlayerUtils.playerHandle(player.vodPlayUrl!);
VideoPlayerUtils.removeInitializedListener(this);
// VideoPlayerUtils.dispose();
super.dispose();
}
}
Loading

0 comments on commit 85d5674

Please sign in to comment.