mirror of
https://github.com/K3vinb5/Unyo.git
synced 2026-06-13 13:49:43 +00:00
Reimplemented from scratch peer2peer, hopefully working now
This commit is contained in:
@@ -5,8 +5,8 @@ import 'package:unyo/screens/screens.dart';
|
||||
import 'package:fvp/fvp.dart' as fvp;
|
||||
|
||||
void main() {
|
||||
//needed for video player!!
|
||||
fvp.registerWith();
|
||||
//needed for video player on desktop!!
|
||||
fvp.registerWith(options: {'platforms': ['windows', 'macos', 'linux']});
|
||||
runApp(const MyApp());
|
||||
doWhenWindowReady(() {
|
||||
appWindow.minSize = const Size(854, 480);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
import 'package:bitsdojo_window/bitsdojo_window.dart';
|
||||
import 'package:desktop_keep_screen_on/desktop_keep_screen_on.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -8,7 +10,8 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:peerdart/peerdart.dart';
|
||||
import 'package:mqtt_client/mqtt_client.dart';
|
||||
import 'package:mqtt_client/mqtt_server_client.dart';
|
||||
import 'package:smooth_video_progress/smooth_video_progress.dart';
|
||||
import 'package:video_player/video_player.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
@@ -17,13 +20,13 @@ import 'package:unyo/widgets/widgets.dart';
|
||||
bool fullScreen = false;
|
||||
|
||||
class VideoScreen extends StatefulWidget {
|
||||
const VideoScreen(
|
||||
{super.key,
|
||||
required this.stream,
|
||||
required this.updateEntry,
|
||||
this.captions,
|
||||
required this.title,
|
||||
});
|
||||
const VideoScreen({
|
||||
super.key,
|
||||
required this.stream,
|
||||
required this.updateEntry,
|
||||
this.captions,
|
||||
required this.title,
|
||||
});
|
||||
|
||||
final String stream;
|
||||
final String? captions;
|
||||
@@ -51,11 +54,10 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
final FocusNode _screenFocusNode = FocusNode();
|
||||
bool keyDelay = false;
|
||||
|
||||
late Peer peer;
|
||||
late DataConnection conn;
|
||||
bool peerConnected = false;
|
||||
String? peerId;
|
||||
String? myPeerId;
|
||||
late MqttServerClient client;
|
||||
late String topic;
|
||||
late String myId;
|
||||
bool connected = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -75,18 +77,7 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
_resetHideControlsTimer();
|
||||
interactScreen(true);
|
||||
_screenFocusNode.requestFocus();
|
||||
setClientPeerConnection();
|
||||
/*Timer(const Duration(milliseconds: 200), () {
|
||||
int attempts = 0;
|
||||
setClientPeerConnection();
|
||||
sleep(const Duration(milliseconds: 1500));
|
||||
if (myPeerId == null && attempts < 10) {
|
||||
attempts++;
|
||||
print("Error $attempts");
|
||||
setClientPeerConnection();
|
||||
return;
|
||||
}
|
||||
});*/
|
||||
setClientMqttConnection(false);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -96,295 +87,317 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void connectToPeer(String receivedPeerId) {
|
||||
peerId = receivedPeerId;
|
||||
try {
|
||||
conn = peer.connect(peerId!);
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
peerConnected = true;
|
||||
|
||||
conn.on("open").listen((event) {
|
||||
setState(() {
|
||||
peerConnected = true;
|
||||
});
|
||||
});
|
||||
conn.on("close").listen((event) {
|
||||
setState(() {
|
||||
peerConnected = false;
|
||||
});
|
||||
});
|
||||
|
||||
conn.on("data").listen((data) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(data)));
|
||||
});
|
||||
|
||||
conn.on("open").listen((_) {
|
||||
conn.send({"connected": myPeerId});
|
||||
});
|
||||
void connectToPeer(String receivedTopic) {
|
||||
client.unsubscribe(topic);
|
||||
connected = false;
|
||||
topic = receivedTopic;
|
||||
setClientMqttConnection(true);
|
||||
}
|
||||
|
||||
void setClientPeerConnection() {
|
||||
peer = Peer(
|
||||
/*options: PeerOptions(
|
||||
host: "kevin-is-awesome.mooo.com",
|
||||
path: "/unyo/",
|
||||
key: "unyo",
|
||||
//port: 9000,
|
||||
secure: true,
|
||||
),*/
|
||||
);
|
||||
void setClientMqttConnection(bool connection) async {
|
||||
client = MqttServerClient('ws://kevin-is-awesome.mooo.com', '',
|
||||
maxConnectionAttempts: 10);
|
||||
|
||||
peer.on("open").listen((id) {
|
||||
setState(() {
|
||||
myPeerId = peer.id;
|
||||
});
|
||||
print("My Peer Id: $myPeerId");
|
||||
});
|
||||
client.useWebSocket = true;
|
||||
client.port = 9001;
|
||||
client.websocketProtocols = MqttClientConstants.protocolsSingleDefault;
|
||||
client.setProtocolV311();
|
||||
client.keepAlivePeriod = 1800;
|
||||
client.logging(on: false);
|
||||
|
||||
peer.on("close").listen((id) {
|
||||
setState(() {
|
||||
peerConnected = false;
|
||||
});
|
||||
});
|
||||
client.onDisconnected = onDisconnected;
|
||||
client.onConnected = onConnected;
|
||||
if (!connection){
|
||||
topic = generateRandomId();
|
||||
myId = generateRandomId();
|
||||
}
|
||||
|
||||
peer.on<DataConnection>("connection").listen((event) {
|
||||
conn = event;
|
||||
try {
|
||||
await client.connect();
|
||||
} on NoConnectionException catch (e) {
|
||||
// Raised by the client when connection fails.
|
||||
print('EXAMPLE::client exception - $e');
|
||||
client.disconnect();
|
||||
//TODO dialog
|
||||
} on SocketException catch (e) {
|
||||
// Raised by the socket layer
|
||||
print('EXAMPLE::socket exception - $e');
|
||||
client.disconnect();
|
||||
//TODO dialog
|
||||
}
|
||||
|
||||
conn.on("data").listen((data) {
|
||||
print("received: $data");
|
||||
/// Check we are connected
|
||||
if (client.connectionStatus!.state != MqttConnectionState.connected) {
|
||||
connected = false;
|
||||
print(
|
||||
'Client connection failed - disconnecting... status is ${client.connectionStatus}');
|
||||
client.disconnect();
|
||||
//TODO dialog
|
||||
return;
|
||||
} else if (connection){
|
||||
connected = true;
|
||||
}
|
||||
|
||||
if (data is Map<String, dynamic>) {
|
||||
if (data.containsKey("seekTo")) {
|
||||
_controller.seekTo(Duration(milliseconds: data["seekTo"]!.toInt()));
|
||||
/*if (!_controller.value.isPlaying) {
|
||||
_controller.play();
|
||||
}*/
|
||||
}
|
||||
client.subscribe(topic, MqttQos.exactlyOnce); //qos 2
|
||||
|
||||
if (data.containsKey("connected")) {
|
||||
peerConnected = true;
|
||||
sendConfirmOrder(data["connected"]);
|
||||
_controller.seekTo(const Duration(milliseconds: 0));
|
||||
_controller.pause();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Connection Successful",
|
||||
style: TextStyle(color: Colors.white)),
|
||||
backgroundColor: const Color.fromARGB(255, 44, 44, 44),
|
||||
content: SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.5,
|
||||
height: MediaQuery.of(context).size.height * 0.5,
|
||||
child: Column(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
style: const ButtonStyle(
|
||||
backgroundColor: MaterialStatePropertyAll(
|
||||
Color.fromARGB(255, 37, 37, 37),
|
||||
),
|
||||
foregroundColor: MaterialStatePropertyAll(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text("Ok",
|
||||
style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
client.updates!.listen((List<MqttReceivedMessage<MqttMessage?>>? c) {
|
||||
final recMess = c![0].payload as MqttPublishMessage;
|
||||
final messageStringAndId = MqttPublishPayload.bytesToStringAsString(recMess.payload.message).split("-");
|
||||
if (messageStringAndId[0] == myId){
|
||||
return;
|
||||
}
|
||||
final messageString = messageStringAndId[1];
|
||||
print("Received: $messageString");
|
||||
|
||||
if (messageString.contains("seekTo")) {
|
||||
_controller.seekTo(Duration(
|
||||
milliseconds: double.parse(messageString.split(":")[1]).toInt()));
|
||||
if (!_controller.value.isPlaying) {
|
||||
_controller.play();
|
||||
}
|
||||
switch (data) {
|
||||
case "pause":
|
||||
_controller.pause();
|
||||
break;
|
||||
case "play":
|
||||
_controller.play();
|
||||
break;
|
||||
case "fifteenplus":
|
||||
_controller.seekTo(
|
||||
Duration(
|
||||
milliseconds:
|
||||
_controller.value.position.inMilliseconds + 15000),
|
||||
);
|
||||
break;
|
||||
case "fifteenminus":
|
||||
_controller.seekTo(
|
||||
Duration(
|
||||
milliseconds:
|
||||
_controller.value.position.inMilliseconds - 15000),
|
||||
);
|
||||
break;
|
||||
case "fiveplus":
|
||||
_controller.seekTo(
|
||||
Duration(
|
||||
milliseconds:
|
||||
_controller.value.position.inMilliseconds + 5000),
|
||||
);
|
||||
break;
|
||||
case "fiveminus":
|
||||
_controller.seekTo(
|
||||
Duration(
|
||||
milliseconds:
|
||||
_controller.value.position.inMilliseconds - 5000),
|
||||
);
|
||||
break;
|
||||
case "confirmed":
|
||||
_controller.seekTo(const Duration(milliseconds: 0));
|
||||
_controller.pause();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Connection Successful",
|
||||
style: TextStyle(color: Colors.white)),
|
||||
backgroundColor: const Color.fromARGB(255, 44, 44, 44),
|
||||
content: SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.5,
|
||||
height: MediaQuery.of(context).size.height * 0.5,
|
||||
child: Column(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
style: const ButtonStyle(
|
||||
backgroundColor: MaterialStatePropertyAll(
|
||||
Color.fromARGB(255, 37, 37, 37),
|
||||
),
|
||||
foregroundColor: MaterialStatePropertyAll(
|
||||
Colors.white,
|
||||
),
|
||||
}
|
||||
|
||||
switch (messageString) {
|
||||
case "pause":
|
||||
_controller.pause();
|
||||
break;
|
||||
case "play":
|
||||
_controller.play();
|
||||
break;
|
||||
case "fifteenplus":
|
||||
_controller.seekTo(
|
||||
Duration(
|
||||
milliseconds:
|
||||
_controller.value.position.inMilliseconds + 15000),
|
||||
);
|
||||
break;
|
||||
case "fifteenminus":
|
||||
_controller.seekTo(
|
||||
Duration(
|
||||
milliseconds:
|
||||
_controller.value.position.inMilliseconds - 15000),
|
||||
);
|
||||
break;
|
||||
case "fiveplus":
|
||||
_controller.seekTo(
|
||||
Duration(
|
||||
milliseconds:
|
||||
_controller.value.position.inMilliseconds + 5000),
|
||||
);
|
||||
break;
|
||||
case "fiveminus":
|
||||
_controller.seekTo(
|
||||
Duration(
|
||||
milliseconds:
|
||||
_controller.value.position.inMilliseconds - 5000),
|
||||
);
|
||||
break;
|
||||
case "confirmed":
|
||||
_controller.seekTo(const Duration(milliseconds: 0));
|
||||
_controller.pause();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Connection Successful",
|
||||
style: TextStyle(color: Colors.white)),
|
||||
backgroundColor: const Color.fromARGB(255, 44, 44, 44),
|
||||
content: SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.5,
|
||||
height: MediaQuery.of(context).size.height * 0.5,
|
||||
child: Column(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
style: const ButtonStyle(
|
||||
backgroundColor: MaterialStatePropertyAll(
|
||||
Color.fromARGB(255, 37, 37, 37),
|
||||
),
|
||||
foregroundColor: MaterialStatePropertyAll(
|
||||
Colors.white,
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text("Ok",
|
||||
style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
],
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text("Ok",
|
||||
style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
break;
|
||||
case "escape":
|
||||
WindowManager.instance.setFullScreen(false);
|
||||
_controller.dispose();
|
||||
interactScreen(false);
|
||||
print(calculatePercentage());
|
||||
if (calculatePercentage() > 0.8) {
|
||||
widget.updateEntry();
|
||||
}
|
||||
Navigator.pop(context);
|
||||
peer.disconnect();
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
conn.on("close").listen((event) {
|
||||
setState(() {
|
||||
peerConnected = false;
|
||||
});
|
||||
});
|
||||
|
||||
peerConnected = true;
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
break;
|
||||
case "escape":
|
||||
WindowManager.instance.setFullScreen(false);
|
||||
_controller.dispose();
|
||||
interactScreen(false);
|
||||
print(calculatePercentage());
|
||||
if (calculatePercentage() > 0.8) {
|
||||
widget.updateEntry();
|
||||
}
|
||||
Navigator.pop(context);
|
||||
client.disconnect();
|
||||
break;
|
||||
case "connected":
|
||||
sendConfirmOrder();
|
||||
_controller.seekTo(const Duration(milliseconds: 0));
|
||||
_controller.pause();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: const Text("Connection Successful",
|
||||
style: TextStyle(color: Colors.white)),
|
||||
backgroundColor: const Color.fromARGB(255, 44, 44, 44),
|
||||
content: SizedBox(
|
||||
width: MediaQuery.of(context).size.width * 0.5,
|
||||
height: MediaQuery.of(context).size.height * 0.5,
|
||||
child: Column(
|
||||
children: [
|
||||
ElevatedButton(
|
||||
style: const ButtonStyle(
|
||||
backgroundColor: MaterialStatePropertyAll(
|
||||
Color.fromARGB(255, 37, 37, 37),
|
||||
),
|
||||
foregroundColor: MaterialStatePropertyAll(
|
||||
Colors.white,
|
||||
),
|
||||
),
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: const Text("Ok",
|
||||
style: TextStyle(color: Colors.white)),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
if(connection){
|
||||
sendConnectedOrder();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
String generateRandomId() {
|
||||
const characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
||||
final random = Random();
|
||||
final idLength = 10; // You can adjust the length of the ID as needed
|
||||
return String.fromCharCodes(
|
||||
List.generate(
|
||||
idLength,
|
||||
(_) => characters.codeUnitAt(random.nextInt(characters.length)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//TODO temp
|
||||
void onDisconnected() {
|
||||
print('EXAMPLE::OnDisconnected client callback - Client disconnection');
|
||||
if (client.connectionStatus!.disconnectionOrigin ==
|
||||
MqttDisconnectionOrigin.solicited) {
|
||||
print('Client disconnected succesfully');
|
||||
}
|
||||
}
|
||||
|
||||
/// The successful connect callback
|
||||
void onConnected() {
|
||||
print('Client connection was sucessful');
|
||||
}
|
||||
|
||||
void sendPauseVideoOrder() {
|
||||
print("$peerConnected pause");
|
||||
if (peerConnected) {
|
||||
conn = peer.connect(peerId!);
|
||||
conn.on("open").listen((_) {
|
||||
conn.send("pause");
|
||||
});
|
||||
print("$connected pause");
|
||||
if (connected) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString("$myId-pause");
|
||||
client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
void sendPlayVideoOrder() {
|
||||
print("$peerConnected play");
|
||||
if (peerConnected) {
|
||||
conn = peer.connect(peerId!);
|
||||
conn.on("open").listen((_) {
|
||||
conn.send("play");
|
||||
});
|
||||
print("$connected play");
|
||||
if (connected) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString("$myId-play");
|
||||
client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
void sendFifteenPosOrder() {
|
||||
print("$peerConnected play");
|
||||
if (peerConnected) {
|
||||
conn = peer.connect(peerId!);
|
||||
conn.on("open").listen((_) {
|
||||
conn.send("fifteenplus");
|
||||
});
|
||||
print("$connected fifteenplus");
|
||||
if (connected) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString("$myId-fifteenplus");
|
||||
client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
void sendFifteenMinOrder() {
|
||||
print("$peerConnected play");
|
||||
if (peerConnected) {
|
||||
conn = peer.connect(peerId!);
|
||||
conn.on("open").listen((_) {
|
||||
conn.send("fifteenminus");
|
||||
});
|
||||
print("$connected fifteenminus");
|
||||
if (connected) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString("$myId-fifteenminus");
|
||||
client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
void sendFivePosOrder() {
|
||||
print("$peerConnected play");
|
||||
if (peerConnected) {
|
||||
conn = peer.connect(peerId!);
|
||||
conn.on("open").listen((_) {
|
||||
conn.send("fiveplus");
|
||||
});
|
||||
print("$connected fiveplus");
|
||||
if (connected) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString("$myId-fiveplus");
|
||||
client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
void sendFiveMinOrder() {
|
||||
print("$peerConnected play");
|
||||
if (peerConnected) {
|
||||
conn = peer.connect(peerId!);
|
||||
conn.on("open").listen((_) {
|
||||
conn.send("fiveminus");
|
||||
});
|
||||
print("$connected fiveminus");
|
||||
if (connected) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString("$myId-fiveminus");
|
||||
client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
void sendSeekToOrder(double time) {
|
||||
print("$peerConnected play");
|
||||
if (peerConnected) {
|
||||
conn = peer.connect(peerId!);
|
||||
conn.on("open").listen((_) {
|
||||
conn.send({"seekTo": time});
|
||||
});
|
||||
print("$connected seekTo");
|
||||
if (connected) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString("$myId-seekTo:$time");
|
||||
client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
void sendConfirmOrder(String receivedPeerId) {
|
||||
peerId = receivedPeerId;
|
||||
if (peerConnected) {
|
||||
conn = peer.connect(peerId!);
|
||||
conn.on("open").listen((_) {
|
||||
conn.send("confirmed");
|
||||
});
|
||||
void sendConfirmOrder() {
|
||||
if (connected) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString("$myId-confirmed");
|
||||
client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
void sendEscapeOrder() {
|
||||
if (peerConnected) {
|
||||
conn = peer.connect(peerId!);
|
||||
conn.on("open").listen((_) {
|
||||
conn.send("escape");
|
||||
});
|
||||
print("$connected escape");
|
||||
if (connected) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString("$myId-escape");
|
||||
client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
void sendConnectedOrder() {
|
||||
if (connected) {
|
||||
final builder = MqttClientPayloadBuilder();
|
||||
builder.addString("$myId-connected");
|
||||
client.publishMessage(topic, MqttQos.exactlyOnce, builder.payload!);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,7 +553,7 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
_resetHideControlsTimer();
|
||||
break;
|
||||
case LogicalKeyboardKey.keyJ:
|
||||
sendFifteenMinOrder();
|
||||
//sendFifteenMinOrder();
|
||||
_controller.seekTo(
|
||||
Duration(
|
||||
milliseconds:
|
||||
@@ -569,7 +582,7 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
if (calculatePercentage() > 0.8) {
|
||||
widget.updateEntry();
|
||||
}
|
||||
peer.disconnect();
|
||||
client.disconnect();
|
||||
Navigator.pop(context);
|
||||
break;
|
||||
default:
|
||||
@@ -677,7 +690,7 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
onExit: onExitSound,
|
||||
connectToPeer: connectToPeer,
|
||||
seekToPeer: sendSeekToOrder,
|
||||
myPeerId: myPeerId ?? "peerId not set",
|
||||
topic: topic,
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -705,7 +718,7 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
if (calculatePercentage() > 0.8) {
|
||||
widget.updateEntry();
|
||||
}
|
||||
peer.disconnect();
|
||||
client.disconnect();
|
||||
Navigator.pop(context);
|
||||
}
|
||||
},
|
||||
@@ -718,7 +731,11 @@ class _VideoScreenState extends State<VideoScreen> {
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(left: 6.0, top: 2.0),
|
||||
child: Text(widget.title, style: const TextStyle(color: Colors.white, fontWeight: FontWeight.normal, fontSize: 15)),
|
||||
child: Text(widget.title,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 15)),
|
||||
),
|
||||
)
|
||||
],
|
||||
|
||||
@@ -15,8 +15,8 @@ class VideoProgressSlider extends StatelessWidget {
|
||||
required this.onEnter,
|
||||
required this.onExit,
|
||||
required this.connectToPeer,
|
||||
required this.myPeerId,
|
||||
required this.seekToPeer,
|
||||
required this.topic,
|
||||
});
|
||||
|
||||
final Duration position;
|
||||
@@ -28,7 +28,7 @@ class VideoProgressSlider extends StatelessWidget {
|
||||
final void Function() onEnter;
|
||||
final void Function() onExit;
|
||||
|
||||
final String myPeerId;
|
||||
final String topic;
|
||||
final void Function(String) connectToPeer;
|
||||
final void Function(double) seekToPeer;
|
||||
final TextEditingController textFieldcontroller = TextEditingController();
|
||||
@@ -91,7 +91,7 @@ class VideoProgressSlider extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SelectableText("Your Id:\n$myPeerId",
|
||||
SelectableText("Your Id:\n$topic",
|
||||
style: const TextStyle(color: Colors.white)),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <bitsdojo_window_linux/bitsdojo_window_plugin.h>
|
||||
#include <flutter_webrtc/flutter_web_r_t_c_plugin.h>
|
||||
#include <fvp/fvp_plugin.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <url_launcher_linux/url_launcher_plugin.h>
|
||||
@@ -17,9 +16,6 @@ void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) bitsdojo_window_linux_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "BitsdojoWindowPlugin");
|
||||
bitsdojo_window_plugin_register_with_registrar(bitsdojo_window_linux_registrar);
|
||||
g_autoptr(FlPluginRegistrar) flutter_webrtc_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterWebRTCPlugin");
|
||||
flutter_web_r_t_c_plugin_register_with_registrar(flutter_webrtc_registrar);
|
||||
g_autoptr(FlPluginRegistrar) fvp_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FvpPlugin");
|
||||
fvp_plugin_register_with_registrar(fvp_registrar);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
bitsdojo_window_linux
|
||||
flutter_webrtc
|
||||
fvp
|
||||
screen_retriever
|
||||
url_launcher_linux
|
||||
|
||||
@@ -7,9 +7,7 @@ import Foundation
|
||||
|
||||
import bitsdojo_window_macos
|
||||
import desktop_keep_screen_on
|
||||
import flutter_webrtc
|
||||
import fvp
|
||||
import path_provider_foundation
|
||||
import screen_retriever
|
||||
import shared_preferences_foundation
|
||||
import url_launcher_macos
|
||||
@@ -19,9 +17,7 @@ import window_manager
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
BitsdojoWindowPlugin.register(with: registry.registrar(forPlugin: "BitsdojoWindowPlugin"))
|
||||
DesktopKeepScreenOnPlugin.register(with: registry.registrar(forPlugin: "DesktopKeepScreenOnPlugin"))
|
||||
FlutterWebRTCPlugin.register(with: registry.registrar(forPlugin: "FlutterWebRTCPlugin"))
|
||||
FvpPlugin.register(with: registry.registrar(forPlugin: "FvpPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
|
||||
|
||||
112
pubspec.lock
112
pubspec.lock
@@ -161,6 +161,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
checked_yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -233,14 +241,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.6"
|
||||
dart_webrtc:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: dart_webrtc
|
||||
sha256: "6b101f3505865150a2b2383089b9d52c56608d1169ef5355d9e25f911afd969d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.2"
|
||||
dbus:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -257,14 +257,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.3"
|
||||
events_emitter:
|
||||
event_bus:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: events_emitter
|
||||
sha256: a075477bdf9c8c0c31bb7c7b7bdd357b4486c34f30163119f96de4e7f54abeff
|
||||
name: event_bus
|
||||
sha256: "44baa799834f4c803921873e7446a2add0f3efa45e101a054b1f0ab9b95f8edc"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.2"
|
||||
version: "2.0.0"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -328,14 +328,6 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_webrtc:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_webrtc
|
||||
sha256: "2f17fb96e0c9c6ff75f6b1c36d94755461fc7f36a5c28386f5ee5a18b98688c8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.48+hotfix.1"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -528,6 +520,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
mqtt_client:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: mqtt_client
|
||||
sha256: "001861aba553eaf419aab60b7956227af47a9d1e1efe0d2fcb3957d3fc30d110"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.2.1"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -544,30 +544,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
path_provider:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider
|
||||
sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
path_provider_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.4"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_foundation
|
||||
sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -592,14 +568,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
peerdart:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: peerdart
|
||||
sha256: a6b066f1ca2c1b44c9ffb30539e94772b62ee199c75d7d277b24f4ef1497568b
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.4"
|
||||
petitparser:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -616,14 +584,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.4"
|
||||
platform_detect:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: platform_detect
|
||||
sha256: "08f4ee79c0e1c4858d37e06b22352a3ebdef5466b613749a3adb03e703d4f5b0"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.11"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -664,14 +624,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.3"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: rxdart
|
||||
sha256: "0c7c0cedd93788d996e33041ffecda924cc54389199cde4e6a34b440f50044cb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.27.7"
|
||||
screen_retriever:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -845,6 +797,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.2"
|
||||
universal_html:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: universal_html
|
||||
sha256: "56536254004e24d9d8cfdb7dbbf09b74cf8df96729f38a2f5c238163e3d58971"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.4"
|
||||
universal_io:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -917,14 +877,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
uuid:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: uuid
|
||||
sha256: "648e103079f7c64a36dc7d39369cabb358d377078a051d6ae2ad3aa539519313"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.7"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -1005,14 +957,6 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.5"
|
||||
webrtc_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webrtc_interface
|
||||
sha256: abec3ab7956bd5ac539cf34a42fa0c82ea26675847c0966bb85160400eea9388
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@@ -45,11 +45,11 @@ dependencies:
|
||||
shelf: ^1.4.1
|
||||
shared_preferences: ^2.2.2
|
||||
desktop_keep_screen_on: ^0.0.1
|
||||
peerdart: ^0.5.4
|
||||
build_runner: ^2.4.9
|
||||
go_router: ^13.2.4
|
||||
icons_launcher: ^2.1.7
|
||||
bitsdojo_window: ^0.1.6
|
||||
mqtt_client: ^10.2.1
|
||||
|
||||
icons_launcher:
|
||||
image_path: 'assets/logo.png'
|
||||
|
||||
29
snap/snapcraft.yaml
Normal file
29
snap/snapcraft.yaml
Normal file
@@ -0,0 +1,29 @@
|
||||
name: unyo
|
||||
version: '0.1.2'
|
||||
summary: An Anime app
|
||||
description: Anime app.
|
||||
|
||||
base: core22
|
||||
confinement: strict
|
||||
grade: stable
|
||||
|
||||
apps:
|
||||
my-flutter-app:
|
||||
command: unyo
|
||||
extensions: [gnome]
|
||||
|
||||
parts:
|
||||
unyo:
|
||||
source: .
|
||||
plugin: flutter
|
||||
flutter-target: lib/main.dart
|
||||
|
||||
# This appears to be needed when building in the Snap Store.
|
||||
build-packages:
|
||||
- curl
|
||||
|
||||
# Limit the architectures to build for to prevent unnecessary builds on
|
||||
# architectures that Flutter doesn't support.
|
||||
architectures:
|
||||
- build-on: [ amd64 ]
|
||||
- build-on: [ arm64 ]
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include <bitsdojo_window_windows/bitsdojo_window_plugin.h>
|
||||
#include <desktop_keep_screen_on/desktop_keep_screen_on_plugin_c_api.h>
|
||||
#include <flutter_webrtc/flutter_web_r_t_c_plugin.h>
|
||||
#include <fvp/fvp_plugin_c_api.h>
|
||||
#include <screen_retriever/screen_retriever_plugin.h>
|
||||
#include <url_launcher_windows/url_launcher_windows.h>
|
||||
@@ -19,8 +18,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
registry->GetRegistrarForPlugin("BitsdojoWindowPlugin"));
|
||||
DesktopKeepScreenOnPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("DesktopKeepScreenOnPluginCApi"));
|
||||
FlutterWebRTCPluginRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterWebRTCPlugin"));
|
||||
FvpPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FvpPluginCApi"));
|
||||
ScreenRetrieverPluginRegisterWithRegistrar(
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
bitsdojo_window_windows
|
||||
desktop_keep_screen_on
|
||||
flutter_webrtc
|
||||
fvp
|
||||
screen_retriever
|
||||
url_launcher_windows
|
||||
|
||||
Reference in New Issue
Block a user