Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Um/asc 16229/view play live stream #200

Merged
merged 10 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,21 @@ android {
multiDexEnabled true
}

packagingOptions {
// Fixes duplicate libraries build issue,
// when your project uses more than one plugin that depend on C++ libs.
pickFirst 'lib/**/libc++_shared.so'
}

buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
minifyEnabled true
proguardFiles getDefaultProguardFile(
'proguard-android-optimize.txt'),
'proguard-rules.pro'
}
}
}
Expand Down
1 change: 1 addition & 0 deletions android/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-keep class org.videolan.libvlc.** { *; }
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<application
android:label="sample_app"
android:name="${applicationName}"
android:requestLegacyExternalStorage="true"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1430;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1430"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
5 changes: 5 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@
<string>We need access to photo library so that photos can be selected</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>
9 changes: 9 additions & 0 deletions lib/core/route/app_route.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,13 @@ class AppRoute {

static const userBlock = 'userBlock';
static const userBlockRoute = '/userBlock';

static const stream = 'streamList';
static const streamRoute = 'streamList';

static const liveStream = 'livestreamList';
static const liveStreamRoute = 'livestreamList';

static const viewStream = 'viewStream';
static const viewStreamRoute = 'viewStream';
}
22 changes: 22 additions & 0 deletions lib/core/route/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import 'package:flutter_social_sample_app/presentation/screen/following_list/fol
import 'package:flutter_social_sample_app/presentation/screen/global_feed/global_feed_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/global_user_search/global_user_search.dart';
import 'package:flutter_social_sample_app/presentation/screen/landing/landing_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/live_stream_list/live_stream_list.dart';
import 'package:flutter_social_sample_app/presentation/screen/login/login_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/message_update/message_update_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/my_follower_list/my_follower_list_screen.dart';
Expand All @@ -39,10 +40,12 @@ import 'package:flutter_social_sample_app/presentation/screen/reaction_list_post
import 'package:flutter_social_sample_app/presentation/screen/rte_event/comment_rte_event_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/rte_event/community_rte_event_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/rte_event/post_rte_event_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/stream_list/stream_list_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/token_exchange/token_exchange_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/user_blocked_list/user_blocked_list_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/user_feed/user_feed_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/user_profile/user_profile_screen.dart';
import 'package:flutter_social_sample_app/presentation/screen/view_stream/view_stream.dart';
import 'package:go_router/go_router.dart';

class AppRouter {
Expand Down Expand Up @@ -94,6 +97,24 @@ class AppRouter {
builder: (context, state) => const GlobalFeedScreen(),
routes: const [],
),
GoRoute(
name: AppRoute.stream,
path: AppRoute.streamRoute,
builder: (context, state) => const StreamListScreen(),
),
GoRoute(
name: AppRoute.liveStream,
path: AppRoute.liveStreamRoute,
builder: (context, state) => const LiveStreamListScreen(),
),
GoRoute(
name: AppRoute.viewStream,
path: AppRoute.viewStreamRoute,
builder: (context, state) {
AmityStream amityStream = state.extra as AmityStream;
return ViewStream(stream: amityStream);
},
),
GoRoute(
name: AppRoute.communityFeed,
path: AppRoute.communityFeedRoute,
Expand All @@ -107,6 +128,7 @@ class AppRouter {
path: AppRoute.communityMemmberRoute,
builder: (context, state) => CommunityMemberScreen(communityId: state.params['communityId']!),
),

GoRoute(
name: AppRoute.userFeed,
path: AppRoute.userFeedRoute,
Expand Down
8 changes: 8 additions & 0 deletions lib/core/widget/feed_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,14 @@ class FeedContentWidget extends StatelessWidget {
);
}

if (amityPostData is LiveStreamData) {
final data = amityPostData as LiveStreamData;
return Container(
// color: Colors.green,
child: Text( 'Linked Stream ID -->>>> ${data.streamId}' ?? 'No Stream ID'),
);
}

return Container(
color: Colors.red,
child: Text('>>>>> $amityPostData <<<<<<'),
Expand Down
14 changes: 14 additions & 0 deletions lib/presentation/screen/dashboard/dashboar_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,20 @@ class _DashboardScreenState extends State<DashboardScreen> {
child: const Text('Get Post'),
),
const SizedBox(height: 20),
TextButton(
onPressed: () {
GoRouter.of(context).pushNamed(AppRoute.stream);
},
child: const Text('Recorded Streams'),
),
const SizedBox(height: 20),
TextButton(
onPressed: () {
GoRouter.of(context).pushNamed(AppRoute.liveStream);
},
child: const Text('Live Streams'),
),
const SizedBox(height: 20),
TextButton(
onPressed: () {
GoRouter.of(context).goNamed(AppRoute.createPollPost);
Expand Down
103 changes: 103 additions & 0 deletions lib/presentation/screen/live_stream_list/live_stream_list.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter_social_sample_app/core/route/app_route.dart';
import 'package:go_router/go_router.dart';

class LiveStreamListScreen extends StatefulWidget {
const LiveStreamListScreen({super.key});

@override
State<LiveStreamListScreen> createState() => _LiveStreamListScreenState();
}

class _LiveStreamListScreenState extends State<LiveStreamListScreen> {

late StreamLiveCollection streamLiveCollection;
List<AmityStream> amityStream = [];
final scrollcontroller = ScrollController();


@override
void initState() {
streamLiveCollection = StreamLiveCollection(
request: () => AmityVideoClient.newStreamRepository()
.getStreams()
.isLive(true)
.status([AmityStreamStatus.live])
.build(),
);

streamLiveCollection.getStreamController().stream.listen((event) {
// print(event.map((e) => "${e.streamId}, ").toList());
if (mounted) {
setState(() {
amityStream = event;
});
}
});

WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
streamLiveCollection.loadNext();
});

scrollcontroller.addListener(pagination);
super.initState();
}

void pagination() {
if ((scrollcontroller.position.pixels ==
(scrollcontroller.position.maxScrollExtent)) &&
streamLiveCollection.hasNextPage()) {
streamLiveCollection.loadNext();
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Live Stream'),
),
body: Scaffold(
body: Column(
children: [
if (streamLiveCollection.isFetching)
Container(
alignment: Alignment.center,
child: const CircularProgressIndicator(),
),
Expanded(
child: amityStream.isEmpty
? Container(
alignment: Alignment.center,
child: const Text('No Stream'),
)
: ListView.builder(
controller: scrollcontroller,
itemBuilder: (context, index) {
return ListTile(
title: Text(amityStream[index].title ?? ""),
subtitle: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(amityStream[index].streamId ?? ""),
Text(amityStream[index].status?.name ?? ""),
Text("User -> ${amityStream[index].user?.displayName}" ),
],
),
onTap: () {
GoRouter.of(context).pushNamed(AppRoute.viewStream,
extra: amityStream[index]);
},
);
},
itemCount: amityStream.length,
),
),
],
),
),
);
}
}
3 changes: 3 additions & 0 deletions lib/presentation/screen/login/login_screen.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:amity_video_player/amity_video_player.dart';
import 'package:flutter/material.dart';
import 'package:flutter_social_sample_app/core/route/app_route.dart';
import 'package:flutter_social_sample_app/core/widget/common_snackbar.dart';
Expand Down Expand Up @@ -125,6 +126,8 @@ class _LoginScreenState extends State<LoginScreen> {
sycInitialization: true,
);

AmityStreamPlayerClient.setup(AmityCoreClient.getConfiguration());

//Login the user
String userId = _userIdTextController.text.trim();
String userDisplayName = _displayNameTextController.text.trim();
Expand Down
101 changes: 101 additions & 0 deletions lib/presentation/screen/stream_list/stream_list_screen.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import 'package:amity_sdk/amity_sdk.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_social_sample_app/core/route/app_route.dart';
import 'package:go_router/go_router.dart';

class StreamListScreen extends StatefulWidget {
const StreamListScreen({super.key});

@override
State<StreamListScreen> createState() => _StreamListScreenState();
}

class _StreamListScreenState extends State<StreamListScreen> {
late StreamLiveCollection streamLiveCollection;
List<AmityStream> amityStream = [];
final scrollcontroller = ScrollController();

@override
void initState() {
streamLiveCollection = StreamLiveCollection(
request: () => AmityVideoClient.newStreamRepository()
.getStreams()
.status([AmityStreamStatus.recorded])
.build(),
);

streamLiveCollection.getStreamController().stream.listen((event) {
// print(event.map((e) => "${e.streamId}, ").toList());
if (mounted) {
setState(() {
amityStream = event;
});
}
});

WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
streamLiveCollection.loadNext();
});

scrollcontroller.addListener(pagination);
super.initState();
}

void pagination() {
if ((scrollcontroller.position.pixels ==
(scrollcontroller.position.maxScrollExtent)) &&
streamLiveCollection.hasNextPage()) {
streamLiveCollection.loadNext();
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Recorded Streams'),
),
body: Scaffold(
body: Column(
children: [
if (streamLiveCollection.isFetching)
Container(
alignment: Alignment.center,
child: const CircularProgressIndicator(),
),
Expanded(
child: amityStream.isEmpty
? Container(
alignment: Alignment.center,
child: const Text('No Stream'),
)
: ListView.builder(
controller: scrollcontroller,
itemBuilder: (context, index) {
return ListTile(
title: Text(amityStream[index].title ?? ""),
subtitle: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(amityStream[index].streamId ?? ""),
Text(amityStream[index].status?.name ?? ""),
Text("User -> ${amityStream[index].user?.displayName}" ),
],
),
onTap: () {
GoRouter.of(context).pushNamed(AppRoute.viewStream,
extra: amityStream[index]);
},
);
},
itemCount: amityStream.length,
),
),
],
),
),
);
}
}
Loading
Loading