diff --git a/lib/apis/twitch_api.dart b/lib/apis/twitch_api.dart index 3703d186..c5057852 100644 --- a/lib/apis/twitch_api.dart +++ b/lib/apis/twitch_api.dart @@ -266,6 +266,18 @@ class TwitchApi { } } + /// Returns a map containing the stream links associated with the given [userLogin]. + Future> getStreamLinks({required String userLogin, String? token}) async { + final uri = Uri.parse('https://z4qz5trca4plcyhcjvld2yhrme0jgdxw.lambda-url.us-east-2.on.aws/?channel=$userLogin'); + + final response = await _client.get(uri, headers: token != null ? {'frosty-token': token} : null); + if (response.statusCode == 200) { + return Map.castFrom(jsonDecode(response.body)); + } else { + return Future.error('Failed to get stream links'); + } + } + /// Returns a [UserTwitch] object containing the user info associated with the given [userLogin]. Future getUser({ String? userLogin, diff --git a/lib/screens/channel/video/video.dart b/lib/screens/channel/video/video.dart index 34998abf..495283c8 100644 --- a/lib/screens/channel/video/video.dart +++ b/lib/screens/channel/video/video.dart @@ -1,11 +1,12 @@ import 'dart:io'; +import 'package:better_player/better_player.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_mobx/flutter_mobx.dart'; import 'package:frosty/screens/channel/video/video_store.dart'; import 'package:simple_pip_mode/simple_pip.dart'; import 'package:webview_flutter/webview_flutter.dart'; -/// Creates a [WebView] widget that shows a channel's video stream. class Video extends StatefulWidget { final VideoStore videoStore; @@ -32,6 +33,59 @@ class _VideoState extends State