add android support
This commit is contained in:
parent
77a5c52c3a
commit
0fce95faa0
@ -10,8 +10,9 @@ import 'platform.dart';
|
|||||||
// main app entry point
|
// main app entry point
|
||||||
void main() async {
|
void main() async {
|
||||||
Log.i("App init!");
|
Log.i("App init!");
|
||||||
if (isDesktop()) {
|
|
||||||
DartVLC.initialize();
|
DartVLC.initialize();
|
||||||
|
if (isDesktop()) {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
await loadDeviceInfo();
|
await loadDeviceInfo();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:openmediacentermobile/videoscreen.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 'api/api.dart';
|
import 'api/api.dart';
|
||||||
import 'platform.dart';
|
import 'platform.dart';
|
||||||
|
123
lib/videoscreen_desktop.dart
Normal file
123
lib/videoscreen_desktop.dart
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
import 'dart:convert';
|
||||||
|
import 'dart:math';
|
||||||
|
|
||||||
|
import 'package:chewie/chewie.dart';
|
||||||
|
import "package:dart_vlc/dart_vlc.dart";
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:video_player/video_player.dart';
|
||||||
|
|
||||||
|
import 'api/api.dart';
|
||||||
|
import 'api/token.dart';
|
||||||
|
import 'log/log.dart';
|
||||||
|
import 'platform.dart';
|
||||||
|
|
||||||
|
class VideoScreen extends StatefulWidget {
|
||||||
|
const VideoScreen({Key? key, required this.videoID}) : super(key: key);
|
||||||
|
final int videoID;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<VideoScreen> createState() => _VideoScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _VideoScreenState extends State<VideoScreen> {
|
||||||
|
late Player player;
|
||||||
|
ChewieController? _chewieController;
|
||||||
|
|
||||||
|
void loadData() async {
|
||||||
|
final data = await API.query("video", "loadVideo", {'MovieId': widget.videoID});
|
||||||
|
|
||||||
|
final d = jsonDecode(data);
|
||||||
|
|
||||||
|
final url = d["MovieUrl"];
|
||||||
|
final token = await Token.getInstance().getToken();
|
||||||
|
if (token == null) return;
|
||||||
|
|
||||||
|
final baseurl = token.domain;
|
||||||
|
// todo not static middle path
|
||||||
|
final path = baseurl + "/videos/vids/" + url;
|
||||||
|
|
||||||
|
if (isDesktop()) {
|
||||||
|
player = Player(id: Random().nextInt(0x7fffffff));
|
||||||
|
final media2 = Media.network(path);
|
||||||
|
|
||||||
|
player.open(
|
||||||
|
media2,
|
||||||
|
autoStart: true, // default
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
final VideoPlayerController _controller = VideoPlayerController.network(path);
|
||||||
|
await _controller.initialize();
|
||||||
|
|
||||||
|
_chewieController = ChewieController(
|
||||||
|
videoPlayerController: _controller,
|
||||||
|
autoPlay: true,
|
||||||
|
looping: true,
|
||||||
|
);
|
||||||
|
|
||||||
|
setState(() {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
|
||||||
|
RawKeyboard.instance.addListener((value) {
|
||||||
|
if (value.logicalKey == LogicalKeyboardKey.arrowRight) {
|
||||||
|
player.seek(player.position.position! + const Duration(seconds: 5));
|
||||||
|
} else if (value.logicalKey == LogicalKeyboardKey.arrowLeft) {
|
||||||
|
player.seek(player.position.position! + const Duration(seconds: -5));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loadData();
|
||||||
|
|
||||||
|
// todo hide appbar after some seonds
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
if (isDesktop()) {
|
||||||
|
player.pause();
|
||||||
|
player.stop();
|
||||||
|
player.dispose();
|
||||||
|
} else {
|
||||||
|
_chewieController?.videoPlayerController.dispose();
|
||||||
|
_chewieController?.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text('Second Route'),
|
||||||
|
),
|
||||||
|
body: Center(child: isDesktop() ? videoDesktop() : videoNotDesktop()),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget videoDesktop() {
|
||||||
|
return Video(
|
||||||
|
player: player,
|
||||||
|
scale: 1.0, // default
|
||||||
|
showControls: true,
|
||||||
|
playlistLength: 1, // default
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget videoNotDesktop() {
|
||||||
|
if (_chewieController == null) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: const [CircularProgressIndicator(), Text("loading...")],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return Chewie(
|
||||||
|
controller: _chewieController!,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,9 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import "package:dart_vlc/dart_vlc.dart";
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
|
||||||
|
|
||||||
import 'api/api.dart';
|
import 'api/api.dart';
|
||||||
import 'api/token.dart';
|
import 'api/token.dart';
|
||||||
import 'platform.dart';
|
|
||||||
|
|
||||||
class VideoScreen extends StatefulWidget {
|
class VideoScreen extends StatefulWidget {
|
||||||
const VideoScreen({Key? key, required this.videoID}) : super(key: key);
|
const VideoScreen({Key? key, required this.videoID}) : super(key: key);
|
||||||
@ -18,8 +14,6 @@ class VideoScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _VideoScreenState extends State<VideoScreen> {
|
class _VideoScreenState extends State<VideoScreen> {
|
||||||
Player player = Player(id: Random().nextInt(0x7fffffff));
|
|
||||||
|
|
||||||
void loadData() async {
|
void loadData() async {
|
||||||
final data = await API.query("video", "loadVideo", {'MovieId': widget.videoID});
|
final data = await API.query("video", "loadVideo", {'MovieId': widget.videoID});
|
||||||
|
|
||||||
@ -33,56 +27,25 @@ class _VideoScreenState extends State<VideoScreen> {
|
|||||||
// todo not static middle path
|
// todo not static middle path
|
||||||
final path = baseurl + "/videos/vids/" + url;
|
final path = baseurl + "/videos/vids/" + url;
|
||||||
|
|
||||||
if (isDesktop()) {
|
|
||||||
final media2 = Media.network(path);
|
|
||||||
|
|
||||||
player.open(
|
|
||||||
media2,
|
|
||||||
autoStart: true, // default
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// todo do mobile web stuff
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
RawKeyboard.instance.addListener((value) {
|
|
||||||
if(value.logicalKey == LogicalKeyboardKey.arrowRight){
|
|
||||||
player.seek(player.position.position! +const Duration(seconds: 5));
|
|
||||||
}else if(value.logicalKey == LogicalKeyboardKey.arrowLeft){
|
|
||||||
player.seek(player.position.position! + const Duration(seconds: -5));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
|
|
||||||
// todo hide appbar after some seonds
|
// todo hide appbar after some seonds
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
void dispose() {
|
|
||||||
super.dispose();
|
|
||||||
player.pause();
|
|
||||||
player.stop();
|
|
||||||
player.dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: const Text('Second Route'),
|
title: const Text('Second Route'),
|
||||||
),
|
),
|
||||||
body: Center(
|
body: const Center(
|
||||||
child: Video(
|
child: Text("Todo to implement")
|
||||||
player: player,
|
|
||||||
scale: 1.0, // default
|
|
||||||
showControls: true,
|
|
||||||
playlistLength: 1, // default
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
114
pubspec.lock
114
pubspec.lock
@ -36,6 +36,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.3.1"
|
version: "1.3.1"
|
||||||
|
chewie:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: chewie
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.3.2"
|
||||||
clock:
|
clock:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -50,6 +57,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.15.0"
|
version: "1.15.0"
|
||||||
|
csslib:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: csslib
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.17.1"
|
||||||
cupertino_icons:
|
cupertino_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -205,6 +219,13 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
html:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: html
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.15.0"
|
||||||
http:
|
http:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -261,6 +282,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.7.0"
|
version: "1.7.0"
|
||||||
|
nested:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: nested
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.0"
|
||||||
path:
|
path:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -330,7 +358,7 @@ packages:
|
|||||||
name: plugin_platform_interface
|
name: plugin_platform_interface
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.2"
|
version: "2.1.2"
|
||||||
process:
|
process:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -338,6 +366,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.2.4"
|
version: "4.2.4"
|
||||||
|
provider:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: provider
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "6.0.2"
|
||||||
sky_engine:
|
sky_engine:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -399,6 +434,83 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.2"
|
||||||
|
very_good_analysis:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: very_good_analysis
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.0"
|
||||||
|
video_player:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: video_player
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.0"
|
||||||
|
video_player_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: video_player_android
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.2"
|
||||||
|
video_player_avfoundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: video_player_avfoundation
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.1"
|
||||||
|
video_player_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: video_player_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "5.1.1"
|
||||||
|
video_player_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: video_player_web
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.7"
|
||||||
|
wakelock:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: wakelock
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.6.1+2"
|
||||||
|
wakelock_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: wakelock_macos
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.4.0"
|
||||||
|
wakelock_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: wakelock_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.3.0"
|
||||||
|
wakelock_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: wakelock_web
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.4.0"
|
||||||
|
wakelock_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: wakelock_windows
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.0"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -40,6 +40,8 @@ dependencies:
|
|||||||
flutter_staggered_grid_view: ^0.6.1
|
flutter_staggered_grid_view: ^0.6.1
|
||||||
dart_vlc: ^0.1.9
|
dart_vlc: ^0.1.9
|
||||||
device_info_plus: ^3.2.3
|
device_info_plus: ^3.2.3
|
||||||
|
video_player: ^2.3.0
|
||||||
|
chewie: ^1.3.2
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
Reference in New Issue
Block a user