new actor view page
fix video view overlay
This commit is contained in:
parent
e1be7bd5e6
commit
ec66a6f4a8
13
lib/app.dart
13
lib/app.dart
@ -1,3 +1,5 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:openmediacentermobile/log/log.dart';
|
||||
import 'package:openmediacentermobile/login/login_screen.dart';
|
||||
@ -5,6 +7,14 @@ import 'package:openmediacentermobile/login/login_screen.dart';
|
||||
import 'DrawerPage.dart';
|
||||
import 'login/logincontext.dart';
|
||||
|
||||
class AppScrollBehavior extends MaterialScrollBehavior {
|
||||
@override
|
||||
Set<PointerDeviceKind> get dragDevices => {
|
||||
PointerDeviceKind.touch,
|
||||
PointerDeviceKind.mouse,
|
||||
};
|
||||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
const App({Key? key}) : super(key: key);
|
||||
|
||||
@ -17,7 +27,8 @@ class App extends StatelessWidget {
|
||||
if (!loginCtx.loggedIn) {
|
||||
return const MaterialApp(home: LoginScreen());
|
||||
} else {
|
||||
return const MaterialApp(
|
||||
return MaterialApp(
|
||||
scrollBehavior: AppScrollBehavior(),
|
||||
home: DrawerPage(
|
||||
title: 'OpenMediaCenter',
|
||||
));
|
||||
|
@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
|
||||
import 'package:openmediacentermobile/platform.dart';
|
||||
import 'package:openmediacentermobile/preview_tile.dart';
|
||||
import 'package:openmediacentermobile/screen_loading.dart';
|
||||
|
||||
class PreviewGrid extends StatefulWidget {
|
||||
const PreviewGrid(
|
||||
@ -49,26 +50,12 @@ class _PreviewGridState extends State<PreviewGrid> {
|
||||
} else if (snapshot.hasData) {
|
||||
return _mainGrid(snapshot.data!, width);
|
||||
} else {
|
||||
return _pageLoading();
|
||||
return ScreenLoading();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _pageLoading() {
|
||||
return Column(children: const <Widget>[
|
||||
SizedBox(
|
||||
width: 60,
|
||||
height: 60,
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 16),
|
||||
child: Text('Awaiting result...'),
|
||||
)
|
||||
]);
|
||||
}
|
||||
|
||||
Widget _mainGrid(List<VideoT> data, double width) {
|
||||
return Stack(
|
||||
children: [
|
||||
|
@ -1,9 +1,9 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:openmediacentermobile/videoscreen_desktop.dart'
|
||||
if (dart.library.html) 'package:openmediacentermobile/videoscreen_web.dart'
|
||||
if (dart.library.io) 'package:openmediacentermobile/videoscreen_desktop.dart';
|
||||
import 'package:openmediacentermobile/video_screen/videoscreen_desktop.dart'
|
||||
if (dart.library.html) 'package:openmediacentermobile/video_screen/videoscreen_web.dart'
|
||||
if (dart.library.io) 'package:openmediacentermobile/video_screen/videoscreen_desktop.dart';
|
||||
|
||||
import 'api/api.dart';
|
||||
import 'platform.dart';
|
||||
|
20
lib/screen_loading.dart
Normal file
20
lib/screen_loading.dart
Normal file
@ -0,0 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class ScreenLoading extends StatelessWidget {
|
||||
const ScreenLoading({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(children: const <Widget>[
|
||||
SizedBox(
|
||||
width: 60,
|
||||
height: 60,
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 16),
|
||||
child: Text('Awaiting result...'),
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
87
lib/video_screen/actor_view.dart
Normal file
87
lib/video_screen/actor_view.dart
Normal file
@ -0,0 +1,87 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:openmediacentermobile/screen_loading.dart';
|
||||
|
||||
import '../api/api.dart';
|
||||
|
||||
class ActorView extends StatefulWidget {
|
||||
const ActorView({Key? key, required this.videoId}) : super(key: key);
|
||||
final int videoId;
|
||||
|
||||
@override
|
||||
State<ActorView> createState() => _ActorViewState();
|
||||
}
|
||||
|
||||
class _ActorViewState extends State<ActorView> {
|
||||
late Future<List<Actor>> _data;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
setState(() {
|
||||
_data = loadData();
|
||||
});
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Future<List<Actor>> loadData() async {
|
||||
final data = await API
|
||||
.query("actor", "getActorsOfVideo", {'MovieId': widget.videoId});
|
||||
if (data == 'null') {
|
||||
return [];
|
||||
}
|
||||
final d = jsonDecode(data);
|
||||
|
||||
List<Actor> dta = (d as List).map((e) => Actor.fromJson(e)).toList();
|
||||
|
||||
return dta;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: _data,
|
||||
builder: (context, AsyncSnapshot<List<Actor>> snapshot) {
|
||||
if (snapshot.hasError) {
|
||||
return Text("Error");
|
||||
} else if (snapshot.hasData) {
|
||||
final actors = snapshot.data;
|
||||
if (actors?.isEmpty ?? true) {
|
||||
return Text("no actors available");
|
||||
} else {
|
||||
return Column(children: _renderActors(snapshot.data!));
|
||||
}
|
||||
} else {
|
||||
return ScreenLoading();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _renderActors(List<Actor> actors) {
|
||||
return actors
|
||||
.map((e) => Text(
|
||||
e.name,
|
||||
style: TextStyle(color: Colors.black),
|
||||
))
|
||||
.toList(growable: false);
|
||||
}
|
||||
}
|
||||
|
||||
class Actor {
|
||||
int actorId;
|
||||
String name;
|
||||
String thumbnail;
|
||||
|
||||
Actor(this.actorId, this.name, this.thumbnail);
|
||||
|
||||
factory Actor.fromJson(dynamic json) {
|
||||
return Actor(json['ActorId'] as int, json['Name'] as String,
|
||||
json['Thumbnail'] as String);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Actor{ActorId: $actorId, Name: $name, Thumbnail: $thumbnail}';
|
||||
}
|
||||
}
|
@ -7,12 +7,12 @@ import "package:dart_vlc/dart_vlc.dart";
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:openmediacentermobile/preview_tile.dart';
|
||||
import 'package:openmediacentermobile/video_screen/actor_view.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
|
||||
import 'api/api.dart';
|
||||
import 'api/token.dart';
|
||||
import 'log/log.dart';
|
||||
import 'platform.dart';
|
||||
import '../api/api.dart';
|
||||
import '../api/token.dart';
|
||||
import '../platform.dart';
|
||||
|
||||
class VideoScreen extends StatefulWidget {
|
||||
const VideoScreen({Key? key, required this.metaData}) : super(key: key);
|
||||
@ -23,14 +23,16 @@ class VideoScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _VideoScreenState extends State<VideoScreen> {
|
||||
Player? _player = isDesktop() ? Player(id: Random().nextInt(0x7fffffff)) : null;
|
||||
Player? _player =
|
||||
isDesktop() ? Player(id: Random().nextInt(0x7fffffff)) : null;
|
||||
ChewieController? _chewieController;
|
||||
|
||||
bool _appBarVisible = true;
|
||||
Timer? _appBarTimer;
|
||||
|
||||
void loadData() async {
|
||||
final data = await API.query("video", "loadVideo", {'MovieId': widget.metaData.id});
|
||||
final data =
|
||||
await API.query("video", "loadVideo", {'MovieId': widget.metaData.id});
|
||||
|
||||
final d = jsonDecode(data);
|
||||
|
||||
@ -50,7 +52,8 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
autoStart: true, // default
|
||||
);
|
||||
} else {
|
||||
final VideoPlayerController _controller = VideoPlayerController.network(path);
|
||||
final VideoPlayerController _controller =
|
||||
VideoPlayerController.network(path);
|
||||
await _controller.initialize();
|
||||
|
||||
_chewieController = ChewieController(
|
||||
@ -73,9 +76,11 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
if (isDesktop()) {
|
||||
RawKeyboard.instance.addListener((value) {
|
||||
if (value.logicalKey == LogicalKeyboardKey.arrowRight) {
|
||||
_player?.seek(_player!.position.position! + const Duration(seconds: 5));
|
||||
_player
|
||||
?.seek(_player!.position.position! + const Duration(seconds: 5));
|
||||
} else if (value.logicalKey == LogicalKeyboardKey.arrowLeft) {
|
||||
_player?.seek(_player!.position.position! + const Duration(seconds: -5));
|
||||
_player
|
||||
?.seek(_player!.position.position! + const Duration(seconds: -5));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -86,13 +91,15 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
if (isDesktop()) {
|
||||
_player?.dispose();
|
||||
} else {
|
||||
_chewieController?.videoPlayerController.dispose();
|
||||
_chewieController?.dispose();
|
||||
}
|
||||
_controller.dispose();
|
||||
_appBarTimer?.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void _setAppBarTimer() {
|
||||
@ -107,12 +114,13 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
);
|
||||
}
|
||||
|
||||
PageController _controller = PageController(
|
||||
initialPage: 0,
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
extendBody: true,
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: _appBarVisible ? AppBar(title: Text(widget.metaData.title)) : null,
|
||||
body: MouseRegion(
|
||||
onHover: (PointerEvent event) {
|
||||
if (event.delta.dx != 0 || event.delta.dy != 0) {
|
||||
@ -122,7 +130,33 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
_setAppBarTimer();
|
||||
}
|
||||
},
|
||||
child: Center(child: isDesktop() ? videoDesktop() : videoNotDesktop()),
|
||||
child: Stack(children: [
|
||||
PageView(
|
||||
scrollDirection: Axis.vertical,
|
||||
controller: _controller,
|
||||
children: [
|
||||
Center(child: isDesktop() ? videoDesktop() : videoNotDesktop()),
|
||||
ActorView(
|
||||
videoId: widget.metaData.id,
|
||||
)
|
||||
]),
|
||||
if (_appBarVisible)
|
||||
new Positioned(
|
||||
top: 0.0,
|
||||
left: 0.0,
|
||||
right: 0.0,
|
||||
child: AppBar(
|
||||
title: Text(widget.metaData.title),
|
||||
leading: new IconButton(
|
||||
icon: new Icon(Icons.arrow_back_ios, color: Colors.grey),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
backgroundColor:
|
||||
Theme.of(context).primaryColor.withOpacity(0.3),
|
||||
elevation: 0.0,
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
);
|
||||
}
|
@ -2,9 +2,9 @@ import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'api/api.dart';
|
||||
import 'api/token.dart';
|
||||
import 'log/log.dart';
|
||||
import '../api/api.dart';
|
||||
import '../api/token.dart';
|
||||
import '../log/log.dart';
|
||||
|
||||
class VideoScreen extends StatefulWidget {
|
||||
const VideoScreen({Key? key, required this.videoID}) : super(key: key);
|
Loading…
Reference in New Issue
Block a user