This commit is contained in:
Daniel 2024-08-13 20:04:37 -04:00
parent 08183de44f
commit 5af1b90ccc
10 changed files with 153 additions and 13 deletions

6
lib/controller/play.dart Normal file
View file

@ -0,0 +1,6 @@
import 'package:audioplayers/audioplayers.dart';
class Player {
final player = AudioPlayer();
Player();
}

View file

@ -1,12 +1,33 @@
import 'package:flutter/material.dart';
import 'package:web_socket_channel/io.dart';
import '../pb/stillbox.pb.dart';
import 'play.dart';
class Client extends ChangeNotifier {
late Uri _wsUri;
class Stillbox extends ChangeNotifier {
Player player = Player();
late IOWebSocketChannel channel;
bool connected = false;
late Uri _wsUri;
LiveState _state = LiveState.LS_LIVE;
Filter? currentFilter;
Call? _currentCall;
set state(LiveState newState) {
channel.sink.add(Live(state: newState, filter: currentFilter));
_state = newState;
notifyListeners();
}
Client() {
LiveState get state {
return _state;
}
Call? get currentCall => _currentCall;
set currentCall(Call? call) {
_currentCall = call;
notifyListeners();
}
Stillbox() {
String socketUrl = 'ws://xenon:3050/ws';
Uri baseUri = Uri.base;
if (baseUri.scheme == 'http' || baseUri.scheme == 'https') {
@ -17,13 +38,15 @@ class Client extends ChangeNotifier {
_wsUri = Uri.parse(socketUrl);
}
bool isConnected() {
return false;
}
void connect() {
channel = IOWebSocketChannel.connect(_wsUri);
channel.stream.listen((event) => _handleData(event));
channel.stream.listen((event) => _handleData(event), onDone: () {
connected = false;
}, onError: (error) {
print(error);
});
connected = true;
notifyListeners();
}
void _handleData(dynamic event) {

View file

@ -2,11 +2,11 @@ import 'package:flutter/material.dart';
import 'views/radio.dart';
import 'package:provider/provider.dart';
import 'views/login.dart';
import 'controller/ws.dart';
import 'controller/stillbox.dart';
void main() {
runApp(ChangeNotifierProvider(
create: (context) => Client(),
create: (context) => Stillbox(),
child: const CallsApp(),
));
}
@ -39,8 +39,6 @@ class CallsHome extends StatefulWidget {
}
class CallsHomeState extends State<CallsHome> {
final c = Client();
@override
void initState() {
super.initState();

View file

@ -6,6 +6,10 @@
#include "generated_plugin_registrant.h"
#include <audioplayers_linux/audioplayers_linux_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) audioplayers_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "AudioplayersLinuxPlugin");
audioplayers_linux_plugin_register_with_registrar(audioplayers_linux_registrar);
}

View file

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

View file

@ -5,8 +5,10 @@
import FlutterMacOS
import Foundation
import audioplayers_darwin
import path_provider_foundation
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AudioplayersDarwinPlugin.register(with: registry.registrar(forPlugin: "AudioplayersDarwinPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
}

View file

@ -9,6 +9,62 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.11.0"
audioplayers:
dependency: "direct main"
description:
name: audioplayers
sha256: c05c6147124cd63e725e861335a8b4d57300b80e6e92cea7c145c739223bbaef
url: "https://pub.dev"
source: hosted
version: "5.2.1"
audioplayers_android:
dependency: transitive
description:
name: audioplayers_android
sha256: b00e1a0e11365d88576320ec2d8c192bc21f1afb6c0e5995d1c57ae63156acb5
url: "https://pub.dev"
source: hosted
version: "4.0.3"
audioplayers_darwin:
dependency: transitive
description:
name: audioplayers_darwin
sha256: "3034e99a6df8d101da0f5082dcca0a2a99db62ab1d4ddb3277bed3f6f81afe08"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
audioplayers_linux:
dependency: transitive
description:
name: audioplayers_linux
sha256: "60787e73fefc4d2e0b9c02c69885402177e818e4e27ef087074cf27c02246c9e"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
audioplayers_platform_interface:
dependency: transitive
description:
name: audioplayers_platform_interface
sha256: "365c547f1bb9e77d94dd1687903a668d8f7ac3409e48e6e6a3668a1ac2982adb"
url: "https://pub.dev"
source: hosted
version: "6.1.0"
audioplayers_web:
dependency: transitive
description:
name: audioplayers_web
sha256: "22cd0173e54d92bd9b2c80b1204eb1eb159ece87475ab58c9788a70ec43c2a62"
url: "https://pub.dev"
source: hosted
version: "4.1.0"
audioplayers_windows:
dependency: transitive
description:
name: audioplayers_windows
sha256: "9536812c9103563644ada2ef45ae523806b0745f7a78e89d1b5fb1951de90e1a"
url: "https://pub.dev"
source: hosted
version: "3.1.0"
boolean_selector:
dependency: transitive
description:
@ -73,6 +129,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.3"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
fixnum:
dependency: "direct main"
description:
@ -99,6 +163,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
google_fonts:
dependency: "direct main"
description:
@ -123,6 +192,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.0.2"
js:
dependency: transitive
description:
name: js
sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3
url: "https://pub.dev"
source: hosted
version: "0.6.7"
leak_tracker:
dependency: transitive
description:
@ -288,6 +365,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.10.0"
sprintf:
dependency: transitive
description:
name: sprintf
sha256: "1fc9ffe69d4df602376b52949af107d8f5703b77cda567c4d7d86a0693120f23"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
stack_trace:
dependency: transitive
description:
@ -312,6 +397,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.2.0"
synchronized:
dependency: transitive
description:
name: synchronized
sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558"
url: "https://pub.dev"
source: hosted
version: "3.1.0+1"
term_glyph:
dependency: transitive
description:
@ -336,6 +429,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.2"
uuid:
dependency: transitive
description:
name: uuid
sha256: "83d37c7ad7aaf9aa8e275490669535c8080377cfa7a7004c24dfac53afffaa90"
url: "https://pub.dev"
source: hosted
version: "4.4.2"
vector_math:
dependency: transitive
description:

View file

@ -40,6 +40,7 @@ dependencies:
protobuf: ^3.1.0
web_socket_channel: ^3.0.1
provider: ^6.1.2
audioplayers: ^5.2.1
dev_dependencies:
flutter_test:

View file

@ -6,6 +6,9 @@
#include "generated_plugin_registrant.h"
#include <audioplayers_windows/audioplayers_windows_plugin.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
AudioplayersWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
}

View file

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST