Skip to content

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: f4c147c7549de641b05ccec9b800842278b45b0f
  • Loading branch information
Madari Developers committed Jan 4, 2025
1 parent 420b4b1 commit 2cba151
Show file tree
Hide file tree
Showing 14 changed files with 484 additions and 108 deletions.
9 changes: 9 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>

<queries>
<package android:name="org.videolan.vlc" />
<package android:name="com.mxtech.videoplayer.ad" />
<package android:name="com.mxtech.videoplayer.pro" />
<package android:name="com.brouken.player" />
</queries>

<application
android:label="madari"
android:icon="@mipmap/launcher_icon"
Expand All @@ -27,6 +34,8 @@
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.HOME"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

<intent-filter>
Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/res/values-night/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
</resources>
2 changes: 2 additions & 0 deletions android/app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
<resources>
<style name="LaunchTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">@drawable/launch_background</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
<style name="NormalTheme" parent="@android:style/Theme.Light.NoTitleBar">
<item name="android:windowBackground">?android:colorBackground</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
</resources>
19 changes: 16 additions & 3 deletions lib/features/connections/service/stremio_connection_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@ class StremioConnectionService extends BaseConnectionService {
for (final addon in config.addons) {
final manifest = await _getManifest(addon);

if (manifest.resources?.contains("meta") != true) {
if (manifest.resources == null) {
continue;
}

bool isMeta = false;
for (final item in manifest.resources!) {
if (item.name == "meta") {
isMeta = true;
break;
}
}

if (isMeta == false) {
continue;
}

Expand Down Expand Up @@ -187,8 +199,9 @@ class StremioConnectionService extends BaseConnectionService {
continue;
}

final hasIdPrefix =
(idPrefixes ?? []).where((item) => meta.id.startsWith(item));
final hasIdPrefix = (idPrefixes ?? []).where(
(item) => meta.id.startsWith(item),
);

if (hasIdPrefix.isEmpty) {
continue;
Expand Down
20 changes: 20 additions & 0 deletions lib/features/connections/widget/base/render_stream_list.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'dart:async';
import 'dart:io';

import 'package:background_downloader/background_downloader.dart';
import 'package:flutter/material.dart';
import 'package:madari_client/features/connection/types/stremio.dart';
import 'package:madari_client/features/connections/service/base_connection_service.dart';
import 'package:madari_client/features/doc_viewer/container/doc_viewer.dart';
import 'package:madari_client/utils/external_player.dart';

import '../../../../utils/load_language.dart';
import '../../../doc_viewer/types/doc_source.dart';
import '../../../downloads/service/service.dart';

Expand Down Expand Up @@ -226,6 +229,23 @@ class _RenderStreamListState extends State<RenderStreamList> {
return;
}

PlaybackConfig config = getPlaybackConfig();

if (config.externalPlayer) {
if (!kIsWeb) {
if (item.source is URLSource ||
item.source is TorrentSource) {
if (config.externalPlayer && Platform.isAndroid) {
openVideoUrlInExternalPlayerAndroid(
videoUrl: (item.source as URLSource).url,
playerPackage: config.currentPlayerPackage,
);
return;
}
}
}
}

Navigator.of(context).push(
MaterialPageRoute(
builder: (ctx) => DocViewer(
Expand Down
14 changes: 10 additions & 4 deletions lib/features/connections/widget/stremio/stremio_item_viewer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,16 @@ class _StremioItemViewerState extends State<StremioItemViewer> {
if (widget.original != null &&
widget.original?.type == "series" &&
widget.original?.videos?.isNotEmpty == true)
StremioItemSeasonSelector(
meta: item!,
library: widget.library,
service: widget.service,
SliverPadding(
padding: EdgeInsets.symmetric(
horizontal: isWideScreen ? (screenWidth - contentWidth) / 2 : 0,
vertical: 0,
),
sliver: StremioItemSeasonSelector(
meta: item!,
library: widget.library,
service: widget.service,
),
),
SliverPadding(
padding: EdgeInsets.symmetric(
Expand Down
111 changes: 72 additions & 39 deletions lib/features/connections/widget/stremio/stremio_season_selector.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:intl/intl.dart' as intl;
import 'package:madari_client/features/connection/types/stremio.dart';
Expand Down Expand Up @@ -89,6 +91,53 @@ class _StremioItemSeasonSelectorState extends State<StremioItemSeasonSelector>
return groupBy(episodes, (Video video) => video.season);
}

void openEpisode({
required int currentSeason,
required Video episode,
}) async {
if (widget.service == null) {
return;
}
final onClose = showModalBottomSheet(
context: context,
builder: (context) {
final meta = widget.meta.copyWith(
id: episode.id,
);

return Scaffold(
appBar: AppBar(
title: Text("Streams for S$currentSeason E${episode.episode}"),
),
body: RenderStreamList(
service: widget.service!,
library: widget.library,
id: meta,
season: currentSeason.toString(),
shouldPop: widget.shouldPop,
),
);
},
);

if (widget.shouldPop) {
final val = await onClose;

if (val is MediaURLSource && context.mounted) {
Navigator.pop(
context,
val,
);
}

return;
}

onClose.then((data) {
getWatchHistory();
});
}

@override
Widget build(BuildContext context) {
final seasons = seasonMap.keys.toList()..sort();
Expand Down Expand Up @@ -123,6 +172,26 @@ class _StremioItemSeasonSelectorState extends State<StremioItemSeasonSelector>
const SizedBox(
height: 12,
),
Center(
child: Container(
constraints: const BoxConstraints(maxWidth: 320),
child: ElevatedButton.icon(
icon: const Icon(Icons.shuffle),
label: const Text("Random Episode"),
onPressed: () {
Random random = Random();
int randomIndex = random.nextInt(
widget.meta.videos!.length,
);

openEpisode(
currentSeason: widget.meta.videos![randomIndex].season,
episode: widget.meta.videos![randomIndex],
);
},
),
),
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
Expand Down Expand Up @@ -162,46 +231,10 @@ class _StremioItemSeasonSelectorState extends State<StremioItemSeasonSelector>
return InkWell(
borderRadius: BorderRadius.circular(12),
onTap: () async {
if (widget.service == null) {
return;
}
final onClose = showModalBottomSheet(
context: context,
builder: (context) {
final meta = widget.meta.copyWith(
id: episode.id,
);

return Scaffold(
appBar: AppBar(
title: const Text("Streams"),
),
body: RenderStreamList(
service: widget.service!,
library: widget.library,
id: meta,
season: currentSeason.toString(),
shouldPop: widget.shouldPop,
),
);
},
openEpisode(
currentSeason: currentSeason,
episode: episode,
);

if (widget.shouldPop) {
final val = await onClose;
if (val is MediaURLSource && context.mounted) {
Navigator.pop(
context,
val,
);
}

return;
}

onClose.then((data) {
getWatchHistory();
});
},
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
Expand Down
Loading

0 comments on commit 2cba151

Please sign in to comment.