MediaMetadata: strings workaround flutter
This commit is contained in:
parent
95cbeaaa5f
commit
b02d66c7d5
4 changed files with 39 additions and 19 deletions
|
|
@ -1,9 +1,12 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_cast_framework/cast.dart';
|
||||
|
||||
/// in seconds
|
||||
const double QUEUE_PRELOAD_TIME = 20;
|
||||
|
||||
const mainVideo = const VideoInfo(
|
||||
"Big Buck Bunny",
|
||||
"Blender Foundation",
|
||||
"https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/BigBuckBunny.mp4",
|
||||
"mp4",
|
||||
596 * 1000,
|
||||
|
|
@ -13,6 +16,8 @@ const mainVideo = const VideoInfo(
|
|||
|
||||
const List<VideoInfo> otherVideos = [
|
||||
const VideoInfo(
|
||||
"Elephants Dream",
|
||||
"Blender Foundation",
|
||||
"https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/ElephantsDream.mp4",
|
||||
"mp4",
|
||||
653 * 1000,
|
||||
|
|
@ -20,6 +25,8 @@ const List<VideoInfo> otherVideos = [
|
|||
"https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/images/780x1200/ElephantsDream-780x1200.jpg",
|
||||
),
|
||||
const VideoInfo(
|
||||
"Sintel",
|
||||
"Blender Foundation",
|
||||
"https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/Sintel.mp4",
|
||||
"mp4",
|
||||
888 * 1000,
|
||||
|
|
@ -27,6 +34,8 @@ const List<VideoInfo> otherVideos = [
|
|||
"https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/images/780x1200/Sintel-780x1200.jpg",
|
||||
),
|
||||
const VideoInfo(
|
||||
"Tears of Steel",
|
||||
"Blender Foundation",
|
||||
"https://commondatastorage.googleapis.com/gtv-videos-bucket/CastVideos/mp4/TearsOfSteel.mp4",
|
||||
"mp4",
|
||||
734 * 1000,
|
||||
|
|
@ -37,6 +46,8 @@ const List<VideoInfo> otherVideos = [
|
|||
|
||||
class VideoInfo {
|
||||
const VideoInfo(
|
||||
this.title,
|
||||
this.studio,
|
||||
this.url,
|
||||
this.type,
|
||||
this.duration,
|
||||
|
|
@ -44,6 +55,8 @@ class VideoInfo {
|
|||
this.poster,
|
||||
);
|
||||
|
||||
final String title;
|
||||
final String studio;
|
||||
final String url;
|
||||
final String type;
|
||||
final int duration;
|
||||
|
|
@ -78,6 +91,10 @@ MediaInfo _getMediaInfo(VideoInfo video) {
|
|||
final bigImg = WebImage()..url = video.poster;
|
||||
final mediaMetadata = MediaMetadata()
|
||||
..mediaType = MediaType.movie
|
||||
..strings = {
|
||||
describeEnum(MediaMetadataKey.title): video.title,
|
||||
describeEnum(MediaMetadataKey.subtitle): video.studio,
|
||||
}
|
||||
..webImages = [
|
||||
img,
|
||||
bigImg,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_cast_framework/cast.dart';
|
||||
|
||||
|
|
@ -11,22 +12,22 @@ class QueueItemHeading extends StatelessWidget {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// final titleText = mediaInfo?.mediaMetadata?.strings[MediaMetadataKey.title]
|
||||
// final subtitleText = mediaInfo?.mediaMetadata?.strings[MediaMetadataKey.subtitle]
|
||||
final titleText = "";
|
||||
final subtitleText = "";
|
||||
final titleText = mediaInfo
|
||||
?.mediaMetadata?.strings?[describeEnum(MediaMetadataKey.title)];
|
||||
final subtitleText = mediaInfo
|
||||
?.mediaMetadata?.strings?[describeEnum(MediaMetadataKey.subtitle)];
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
titleText,
|
||||
titleText ?? "",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
),
|
||||
Container(height: 2),
|
||||
Text(
|
||||
subtitleText,
|
||||
subtitleText ?? "",
|
||||
overflow: TextOverflow.ellipsis,
|
||||
maxLines: 1,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../cast.dart';
|
||||
|
|
@ -137,18 +138,17 @@ class _ExpandedControlsState extends State<ExpandedControls> {
|
|||
}
|
||||
|
||||
Widget _getDecoratedToolbar(MediaInfo? mediaInfo) {
|
||||
// Title and subtitle can't be retrieved at the moment
|
||||
// final title = mediaInfo?.mediaMetadata?.strings[MediaMetadataKey.title]
|
||||
// final subtitle = mediaInfo?.mediaMetadata?.strings[MediaMetadataKey.subtitle]
|
||||
final title = "";
|
||||
final subtitle = "";
|
||||
final title = mediaInfo
|
||||
?.mediaMetadata?.strings?[describeEnum(MediaMetadataKey.title)];
|
||||
final subtitle = mediaInfo
|
||||
?.mediaMetadata?.strings?[describeEnum(MediaMetadataKey.subtitle)];
|
||||
|
||||
return Container(
|
||||
decoration: _topDownBlackGradient,
|
||||
child: ExpandedControlsToolbar(
|
||||
castFramework: widget.castFramework,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
title: title ?? "",
|
||||
subtitle: subtitle ?? "",
|
||||
onBackTapped: widget.onCloseRequested,
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../cast.dart';
|
||||
|
|
@ -22,18 +23,19 @@ class MiniController extends StatelessWidget {
|
|||
Widget _getControls(MediaStatus? status) {
|
||||
final thumbnail = MiniControllerThumbnail(mediaInfo: status?.mediaInfo);
|
||||
|
||||
// final titleText = mediaInfo?.mediaMetadata?.strings[MediaMetadataKey.title]
|
||||
// final subtitleText = mediaInfo?.mediaMetadata?.strings[MediaMetadataKey.subtitle]
|
||||
final titleText = "";
|
||||
final subtitleText = "";
|
||||
final mediaInfo = status?.mediaInfo;
|
||||
final titleText = mediaInfo
|
||||
?.mediaMetadata?.strings?[describeEnum(MediaMetadataKey.title)];
|
||||
final subtitleText = mediaInfo
|
||||
?.mediaMetadata?.strings?[describeEnum(MediaMetadataKey.subtitle)];
|
||||
final title = Text(
|
||||
titleText,
|
||||
titleText ?? "",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(fontWeight: FontWeight.w500),
|
||||
);
|
||||
final subtitle = Text(
|
||||
subtitleText,
|
||||
subtitleText ?? "",
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: Colors.grey),
|
||||
|
|
|
|||
Loading…
Reference in a new issue