load about from remote url
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:ything_radio/SafeZone.dart';
|
import 'package:ything_radio/SafeZone.dart';
|
||||||
|
|
||||||
|
import 'Globals.dart';
|
||||||
|
|
||||||
class About extends StatelessWidget {
|
class About extends StatelessWidget {
|
||||||
const About({super.key});
|
const About({super.key});
|
||||||
|
|
||||||
@@ -17,31 +19,9 @@ class About extends StatelessWidget {
|
|||||||
child: SafeZone(
|
child: SafeZone(
|
||||||
child: DefaultTextStyle(
|
child: DefaultTextStyle(
|
||||||
style: Theme.of(context).textTheme.bodyLarge!,
|
style: Theme.of(context).textTheme.bodyLarge!,
|
||||||
child: const SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: Text(
|
child: Text(
|
||||||
'Ything Radio is an app that is intended to provide a demonstration of the '
|
getAboutText(),
|
||||||
'open source ything_radio app. This app is used to provide the ability for the '
|
|
||||||
'"look and feel" of the app to be tested on real devices for those wishing to '
|
|
||||||
'either use the code as a template for themselves; or, alternatively, have Ything LLC '
|
|
||||||
'create a custom app for them!'
|
|
||||||
'\n\n'
|
|
||||||
'This app intentionally does not provide a method to change the streaming source '
|
|
||||||
'as it is intended for use by internet radio stations to provide a dedicated app '
|
|
||||||
'for their radio station. This is not intended to be an app for generic usage for '
|
|
||||||
'multiple radio stations, a discovery platform, or to facilitate user input for '
|
|
||||||
'internet radio sites.'
|
|
||||||
'\n\n'
|
|
||||||
'This app has been designed to run across all platforms!'
|
|
||||||
'\n\n'
|
|
||||||
'Android, iOS, MacOS, Windows, Linux, and Web!'
|
|
||||||
'\n\n'
|
|
||||||
'Have a single unified experience across all platforms for your users!'
|
|
||||||
'\n\n'
|
|
||||||
'Want to have us modify this app for you? Reach out at info@ything.net '
|
|
||||||
'We can add additional features for you! Schedule views, up next listings, '
|
|
||||||
'and even custom user interactivity! '
|
|
||||||
'\n\n'
|
|
||||||
'We look forward to hearing from you soon! We would love to build your app!',
|
|
||||||
textAlign: TextAlign.justify,
|
textAlign: TextAlign.justify,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import 'ListenHandler.dart';
|
|||||||
late final ListenHandler _listenHandler;
|
late final ListenHandler _listenHandler;
|
||||||
late final AudioSession _session;
|
late final AudioSession _session;
|
||||||
|
|
||||||
final String _fallback =
|
const String _fallback =
|
||||||
"https://generic.ything.app/music/separation-185196.mp3";
|
"https://generic.ything.app/music/separation-185196.mp3";
|
||||||
final _urlSource = Uri.parse("https://generic.ything.app/music/player.url");
|
final _urlSource = Uri.parse("https://generic.ything.app/music/player.url");
|
||||||
late final String _radioUrl;
|
late final String _radioUrl;
|
||||||
@@ -17,12 +17,33 @@ Future<void> loadCurrentUrl() async {
|
|||||||
final resp = await http.get(_urlSource);
|
final resp = await http.get(_urlSource);
|
||||||
if (resp.statusCode == 200) {
|
if (resp.statusCode == 200) {
|
||||||
_radioUrl = resp.body.trim();
|
_radioUrl = resp.body.trim();
|
||||||
|
print('Loaded remote url');
|
||||||
} else {
|
} else {
|
||||||
_radioUrl = _fallback;
|
_radioUrl = _fallback;
|
||||||
print('Request for current streaming url failed');
|
print('Request for current streaming url failed, using fallback url');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const String _fallbackAbout =
|
||||||
|
"Ything Radio is an internet radio streaming application.";
|
||||||
|
final _urlAbout =
|
||||||
|
Uri.parse("https://generic.ything.app/ything_radio/about.txt");
|
||||||
|
late final String _remoteAbout;
|
||||||
|
|
||||||
|
Future<void> loadAboutUrl() async {
|
||||||
|
final resp = await http.get(_urlAbout);
|
||||||
|
|
||||||
|
if (resp.statusCode == 200) {
|
||||||
|
_remoteAbout = resp.body;
|
||||||
|
print('Loaded remote about');
|
||||||
|
} else {
|
||||||
|
_remoteAbout = _fallbackAbout;
|
||||||
|
print('Request for remote about failed, using fallback about');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getAboutText() => _remoteAbout;
|
||||||
|
|
||||||
Future<void> setupListenHandler() async {
|
Future<void> setupListenHandler() async {
|
||||||
_listenHandler = await AudioService.init(
|
_listenHandler = await AudioService.init(
|
||||||
builder: () => ListenHandler(),
|
builder: () => ListenHandler(),
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import 'YthingRadio.dart';
|
|||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
await loadCurrentUrl();
|
await loadCurrentUrl();
|
||||||
|
await loadAboutUrl();
|
||||||
await setupListenHandler();
|
await setupListenHandler();
|
||||||
runApp(const YthingRadio());
|
runApp(const YthingRadio());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user