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