-
Notifications
You must be signed in to change notification settings - Fork 853
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: local test server * fix: disable web security for web workflow
- Loading branch information
Showing
26 changed files
with
255 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
include: package:flame_lint/analysis_options.yaml | ||
|
||
linter: | ||
rules: | ||
do_not_use_environment: false |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# https://dart.dev/guides/libraries/private-files | ||
.DS_Store | ||
.atom/ | ||
.idea | ||
.packages | ||
.pub/ | ||
.dart_tool/ | ||
build/ | ||
ios/.generated/ | ||
packages | ||
pubspec.lock | ||
.flutter-plugins | ||
flutter_export_environment.sh | ||
.last_build_id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
A simple HTTP server to provide audio sources using [package:shelf](https://pub.dev/packages/shelf). | ||
This server listens to loop-back (localhost, 127.0.0.1). | ||
|
||
To run this server locally, run as follows: | ||
|
||
```bash | ||
$ dart run bin/server.dart | ||
``` | ||
|
||
Environment variables: | ||
|
||
- `LATENCY`: the timeout until the server should respond in milliseconds, default: `0`. | ||
- `PORT`: the port the server should listen on, default: `8080`. | ||
- `LOG_REQUESTS`: log the network requests, default: `false`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
include: package:flame_lint/analysis_options.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// ignore_for_file: avoid_print | ||
import 'dart:io'; | ||
|
||
import 'package:shelf/shelf.dart'; | ||
import 'package:shelf/shelf_io.dart' as shelf_io; | ||
import 'package:shelf_static/shelf_static.dart' as shelf_static; | ||
|
||
Future<void> main() async { | ||
final port = int.parse(Platform.environment['PORT'] ?? '8080'); | ||
final requestTimeoutMillis = | ||
int.parse(Platform.environment['LATENCY'] ?? '0'); | ||
final isLogRequests = | ||
(Platform.environment['LOG_REQUESTS'] ?? 'false') == 'true'; | ||
|
||
final cascade = Cascade().add(_staticHandler); | ||
|
||
var pipeline = const Pipeline(); | ||
if (isLogRequests) { | ||
pipeline = pipeline.addMiddleware(logRequests()); | ||
} | ||
|
||
final handler = pipeline | ||
.addMiddleware( | ||
(innerHandler) => (req) async { | ||
await Future<void>.delayed( | ||
Duration(milliseconds: requestTimeoutMillis), | ||
); | ||
return await innerHandler(req); | ||
}, | ||
) | ||
.addHandler(cascade.handler); | ||
|
||
final server = await shelf_io.serve( | ||
handler, | ||
InternetAddress.loopbackIPv4, | ||
port, | ||
); | ||
|
||
// TODO(Gustl22): provide an audio streaming endpoint: | ||
// Inspiration: https://github.com/daspinola/video-stream-sample/blob/master/server.js | ||
|
||
print( | ||
'Serving at http://${server.address.host}:${server.port} with latency of $requestTimeoutMillis ms', | ||
); | ||
} | ||
|
||
final _staticHandler = shelf_static.createStaticHandler( | ||
'public', | ||
defaultDocument: 'index.html', | ||
serveFilesOutsidePath: true, | ||
); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../../LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../assets |
25 changes: 25 additions & 0 deletions
25
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers.m3u8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#EXTM3U | ||
#EXT-X-VERSION:3 | ||
#EXT-X-TARGETDURATION:6 | ||
#EXT-X-MEDIA-SEQUENCE:0 | ||
#EXT-X-PLAYLIST-TYPE:VOD | ||
#EXTINF:6.400000, | ||
nasa_power_of_the_rovers0.ts | ||
#EXTINF:6.400000, | ||
nasa_power_of_the_rovers1.ts | ||
#EXTINF:6.400000, | ||
nasa_power_of_the_rovers2.ts | ||
#EXTINF:6.400000, | ||
nasa_power_of_the_rovers3.ts | ||
#EXTINF:6.400000, | ||
nasa_power_of_the_rovers4.ts | ||
#EXTINF:6.400000, | ||
nasa_power_of_the_rovers5.ts | ||
#EXTINF:6.400000, | ||
nasa_power_of_the_rovers6.ts | ||
#EXTINF:6.400000, | ||
nasa_power_of_the_rovers7.ts | ||
#EXTINF:6.400000, | ||
nasa_power_of_the_rovers8.ts | ||
#EXTINF:2.410311, | ||
nasa_power_of_the_rovers9.ts |
Binary file added
BIN
+114 KB
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers0.ts
Binary file not shown.
Binary file added
BIN
+110 KB
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers1.ts
Binary file not shown.
Binary file added
BIN
+106 KB
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers2.ts
Binary file not shown.
Binary file added
BIN
+103 KB
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers3.ts
Binary file not shown.
Binary file added
BIN
+104 KB
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers4.ts
Binary file not shown.
Binary file added
BIN
+105 KB
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers5.ts
Binary file not shown.
Binary file added
BIN
+111 KB
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers6.ts
Binary file not shown.
Binary file added
BIN
+109 KB
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers7.ts
Binary file not shown.
Binary file added
BIN
+110 KB
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers8.ts
Binary file not shown.
Binary file added
BIN
+41.7 KB
packages/audioplayers/example/server/public/files/live_streams/nasa_power_of_the_rovers9.ts
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="icon" sizes="64x64" href="favicon_64.png"> | ||
<title>Audioplayers Test Server</title> | ||
</head> | ||
|
||
<style> | ||
body { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
font-family: sans-serif; | ||
min-height: 100vh; | ||
margin: 0; | ||
} | ||
|
||
p { | ||
margin-top: 1rem; | ||
font-size: large; | ||
max-width: 600px; | ||
} | ||
|
||
img { | ||
max-width: 70vw; | ||
} | ||
|
||
code { | ||
background: #eee; | ||
padding: 3px; | ||
} | ||
|
||
.centerFlex { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.centerFlex > * { | ||
padding: 10px; | ||
} | ||
|
||
#content { | ||
flex: 1; | ||
} | ||
|
||
footer { | ||
background: lightgrey; | ||
width: 100%; | ||
justify-content: center; | ||
align-items: center; | ||
display: flex; | ||
} | ||
</style> | ||
|
||
<body> | ||
<div id="content"> | ||
|
||
<div class="centerFlex"> | ||
<img src="/favicon_64.png" alt="Favicon"> | ||
<h1>Audioplayers Test Server</h1> | ||
</div> | ||
<p>This server provides audio files and streams to test <a | ||
href="https://pub.dev/packages/audioplayers">Audioplayers</a> | ||
package:</p> | ||
<ul> | ||
<li><a href="/files/audio/laser.wav">/files/audio/ambient_c_motion.mp3</a></li> | ||
<li><a href="/files/audio/coins.wav">/files/audio/coins.wav</a></li> | ||
<li><a href="/files/audio/laser.wav">/files/audio/laser.wav</a></li> | ||
<li><a href="/files/audio/nasa_on_a_mission.mp3">/files/audio/nasa_on_a_mission.mp3</a></li> | ||
<li> | ||
<a href="/files/live_streams/nasa_power_of_the_rovers.m3u8">/files/live_streams/nasa_power_of_the_rovers.m3u8</a> | ||
</li> | ||
</ul> | ||
</div> | ||
<footer> | ||
<a href="/files/LICENSE">License</a> | ||
</footer> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: audioplayers_test_server | ||
publish_to: none | ||
|
||
environment: | ||
sdk: ">=2.12.0 <3.0.0" | ||
|
||
dependencies: | ||
shelf: ^1.2.0 | ||
shelf_router: ^1.0.0 | ||
shelf_static: ^1.0.0 | ||
|
||
dev_dependencies: | ||
flame_lint: ^0.1.0 | ||
http: ^0.13.0 |