From 81dd86692bceac6ca1b7608fc33d0a86591ffe49 Mon Sep 17 00:00:00 2001 From: gianlucaparadise Date: Fri, 12 Nov 2021 06:54:19 +0100 Subject: [PATCH] RemoteMediaClient: Removed Map - because of https://github.com/flutter/flutter/issues/93525 --- .../PlatformBridgeApis.java | 43 ----------- .../media/MediaLoadRequestDataHelper.kt | 72 +++++++++---------- ios/Classes/PlatformBridgeApis.h | 32 --------- ios/Classes/PlatformBridgeApis.m | 6 +- .../SwiftFlutterCastFrameworkPlugin.swift | 4 ++ lib/src/PlatformBridgeApis.dart | 34 --------- lib/src/PlatformBridgeApisDefinition.dart | 2 +- 7 files changed, 42 insertions(+), 151 deletions(-) diff --git a/android/src/main/java/com/gianlucaparadise/flutter_cast_framework/PlatformBridgeApis.java b/android/src/main/java/com/gianlucaparadise/flutter_cast_framework/PlatformBridgeApis.java index a0fc433..e9e49f8 100644 --- a/android/src/main/java/com/gianlucaparadise/flutter_cast_framework/PlatformBridgeApis.java +++ b/android/src/main/java/com/gianlucaparadise/flutter_cast_framework/PlatformBridgeApis.java @@ -46,42 +46,6 @@ public class PlatformBridgeApis { } } - public enum MediaMetadataKey { - albumArtist(0), - albumTitle(1), - artist(2), - bookTitle(3), - broadcastDate(4), - chapterNumber(5), - chapterTitle(6), - composer(7), - creationDate(8), - discNumber(9), - episodeNumber(10), - height(11), - locationLatitude(12), - locationLongitude(13), - locationName(14), - queueItemId(15), - releaseDate(16), - seasonNumber(17), - sectionDuration(18), - sectionStartAbsoluteTime(19), - sectionStartTimeInContainer(20), - sectionStartTimeInMedia(21), - seriesTitle(22), - studio(23), - subtitle(24), - title(25), - trackNumber(26), - width(27); - - private int index; - private MediaMetadataKey(final int index) { - this.index = index; - } - } - public enum TrackType { unknown(0), text(1), @@ -209,10 +173,6 @@ public class PlatformBridgeApis { public MediaType getMediaType() { return mediaType; } public void setMediaType(MediaType setterArg) { this.mediaType = setterArg; } - private Map strings; - public Map getStrings() { return strings; } - public void setStrings(Map setterArg) { this.strings = setterArg; } - private List webImages; public List getWebImages() { return webImages; } public void setWebImages(List setterArg) { this.webImages = setterArg; } @@ -220,7 +180,6 @@ public class PlatformBridgeApis { Map toMap() { Map toMapResult = new HashMap<>(); toMapResult.put("mediaType", mediaType.index); - toMapResult.put("strings", strings); toMapResult.put("webImages", webImages); return toMapResult; } @@ -228,8 +187,6 @@ public class PlatformBridgeApis { MediaMetadata fromMapResult = new MediaMetadata(); Object mediaType = map.get("mediaType"); fromMapResult.mediaType = MediaType.values()[(int)mediaType]; - Object strings = map.get("strings"); - fromMapResult.strings = (Map)strings; Object webImages = map.get("webImages"); fromMapResult.webImages = (List)webImages; return fromMapResult; diff --git a/android/src/main/kotlin/com/gianlucaparadise/flutter_cast_framework/media/MediaLoadRequestDataHelper.kt b/android/src/main/kotlin/com/gianlucaparadise/flutter_cast_framework/media/MediaLoadRequestDataHelper.kt index f8d80d4..fea8261 100644 --- a/android/src/main/kotlin/com/gianlucaparadise/flutter_cast_framework/media/MediaLoadRequestDataHelper.kt +++ b/android/src/main/kotlin/com/gianlucaparadise/flutter_cast_framework/media/MediaLoadRequestDataHelper.kt @@ -50,10 +50,10 @@ fun getMediaMetadata(mediaMetadata: PlatformBridgeApis.MediaMetadata) : MediaMet val mediaType = getMediaType(mediaMetadata.mediaType) val result = MediaMetadata(mediaType) - mediaMetadata.strings.forEach { - val key = getMediaMetadataKey(it.key) - result.putString(key, it.value) - } +// mediaMetadata.strings.forEach { +// val key = getMediaMetadataKey(it.key) +// result.putString(key, it.value) +// } mediaMetadata.webImages.forEach { val uri = Uri.parse(it.url) @@ -76,38 +76,38 @@ fun getMediaType(mediaType: PlatformBridgeApis.MediaType) : Int { } } -fun getMediaMetadataKey(mediaMetadataKey: PlatformBridgeApis.MediaMetadataKey) : String { - return when (mediaMetadataKey) { - PlatformBridgeApis.MediaMetadataKey.albumArtist -> "com.google.android.gms.cast.metadata.ALBUM_ARTIST" - PlatformBridgeApis.MediaMetadataKey.albumTitle -> "com.google.android.gms.cast.metadata.ALBUM_TITLE" - PlatformBridgeApis.MediaMetadataKey.artist -> "com.google.android.gms.cast.metadata.ARTIST" - PlatformBridgeApis.MediaMetadataKey.bookTitle -> "com.google.android.gms.cast.metadata.BOOK_TITLE" - PlatformBridgeApis.MediaMetadataKey.broadcastDate -> "com.google.android.gms.cast.metadata.BROADCAST_DATE" - PlatformBridgeApis.MediaMetadataKey.chapterNumber -> "com.google.android.gms.cast.metadata.CHAPTER_NUMBER" - PlatformBridgeApis.MediaMetadataKey.chapterTitle -> "com.google.android.gms.cast.metadata.CHAPTER_TITLE" - PlatformBridgeApis.MediaMetadataKey.composer -> "com.google.android.gms.cast.metadata.COMPOSER" - PlatformBridgeApis.MediaMetadataKey.creationDate -> "com.google.android.gms.cast.metadata.CREATION_DATE" - PlatformBridgeApis.MediaMetadataKey.discNumber -> "com.google.android.gms.cast.metadata.DISC_NUMBER" - PlatformBridgeApis.MediaMetadataKey.episodeNumber -> "com.google.android.gms.cast.metadata.EPISODE_NUMBER" - PlatformBridgeApis.MediaMetadataKey.height -> "com.google.android.gms.cast.metadata.HEIGHT" - PlatformBridgeApis.MediaMetadataKey.locationLatitude -> "com.google.android.gms.cast.metadata.LOCATION_LATITUDE" - PlatformBridgeApis.MediaMetadataKey.locationLongitude -> "com.google.android.gms.cast.metadata.LOCATION_LONGITUDE" - PlatformBridgeApis.MediaMetadataKey.locationName -> "com.google.android.gms.cast.metadata.LOCATION_NAME" - PlatformBridgeApis.MediaMetadataKey.queueItemId -> "com.google.android.gms.cast.metadata.QUEUE_ITEM_ID" - PlatformBridgeApis.MediaMetadataKey.releaseDate -> "com.google.android.gms.cast.metadata.RELEASE_DATE" - PlatformBridgeApis.MediaMetadataKey.seasonNumber -> "com.google.android.gms.cast.metadata.SEASON_NUMBER" - PlatformBridgeApis.MediaMetadataKey.sectionDuration -> "com.google.android.gms.cast.metadata.SECTION_DURATION" - PlatformBridgeApis.MediaMetadataKey.sectionStartAbsoluteTime -> "com.google.android.gms.cast.metadata.SECTION_START_ABSOLUTE_TIME" - PlatformBridgeApis.MediaMetadataKey.sectionStartTimeInContainer -> "com.google.android.gms.cast.metadata.SECTION_START_TIME_IN_CONTAINER" - PlatformBridgeApis.MediaMetadataKey.sectionStartTimeInMedia -> "com.google.android.gms.cast.metadata.SECTION_START_TIME_IN_MEDIA" - PlatformBridgeApis.MediaMetadataKey.seriesTitle -> "com.google.android.gms.cast.metadata.SERIES_TITLE" - PlatformBridgeApis.MediaMetadataKey.studio -> "com.google.android.gms.cast.metadata.STUDIO" - PlatformBridgeApis.MediaMetadataKey.subtitle -> "com.google.android.gms.cast.metadata.SUBTITLE" - PlatformBridgeApis.MediaMetadataKey.title -> "com.google.android.gms.cast.metadata.TITLE" - PlatformBridgeApis.MediaMetadataKey.trackNumber -> "com.google.android.gms.cast.metadata.TRACK_NUMBER" - PlatformBridgeApis.MediaMetadataKey.width -> "com.google.android.gms.cast.metadata.WIDTH" - } -} +//fun getMediaMetadataKey(mediaMetadataKey: PlatformBridgeApis.MediaMetadataKey) : String { +// return when (mediaMetadataKey) { +// PlatformBridgeApis.MediaMetadataKey.albumArtist -> "com.google.android.gms.cast.metadata.ALBUM_ARTIST" +// PlatformBridgeApis.MediaMetadataKey.albumTitle -> "com.google.android.gms.cast.metadata.ALBUM_TITLE" +// PlatformBridgeApis.MediaMetadataKey.artist -> "com.google.android.gms.cast.metadata.ARTIST" +// PlatformBridgeApis.MediaMetadataKey.bookTitle -> "com.google.android.gms.cast.metadata.BOOK_TITLE" +// PlatformBridgeApis.MediaMetadataKey.broadcastDate -> "com.google.android.gms.cast.metadata.BROADCAST_DATE" +// PlatformBridgeApis.MediaMetadataKey.chapterNumber -> "com.google.android.gms.cast.metadata.CHAPTER_NUMBER" +// PlatformBridgeApis.MediaMetadataKey.chapterTitle -> "com.google.android.gms.cast.metadata.CHAPTER_TITLE" +// PlatformBridgeApis.MediaMetadataKey.composer -> "com.google.android.gms.cast.metadata.COMPOSER" +// PlatformBridgeApis.MediaMetadataKey.creationDate -> "com.google.android.gms.cast.metadata.CREATION_DATE" +// PlatformBridgeApis.MediaMetadataKey.discNumber -> "com.google.android.gms.cast.metadata.DISC_NUMBER" +// PlatformBridgeApis.MediaMetadataKey.episodeNumber -> "com.google.android.gms.cast.metadata.EPISODE_NUMBER" +// PlatformBridgeApis.MediaMetadataKey.height -> "com.google.android.gms.cast.metadata.HEIGHT" +// PlatformBridgeApis.MediaMetadataKey.locationLatitude -> "com.google.android.gms.cast.metadata.LOCATION_LATITUDE" +// PlatformBridgeApis.MediaMetadataKey.locationLongitude -> "com.google.android.gms.cast.metadata.LOCATION_LONGITUDE" +// PlatformBridgeApis.MediaMetadataKey.locationName -> "com.google.android.gms.cast.metadata.LOCATION_NAME" +// PlatformBridgeApis.MediaMetadataKey.queueItemId -> "com.google.android.gms.cast.metadata.QUEUE_ITEM_ID" +// PlatformBridgeApis.MediaMetadataKey.releaseDate -> "com.google.android.gms.cast.metadata.RELEASE_DATE" +// PlatformBridgeApis.MediaMetadataKey.seasonNumber -> "com.google.android.gms.cast.metadata.SEASON_NUMBER" +// PlatformBridgeApis.MediaMetadataKey.sectionDuration -> "com.google.android.gms.cast.metadata.SECTION_DURATION" +// PlatformBridgeApis.MediaMetadataKey.sectionStartAbsoluteTime -> "com.google.android.gms.cast.metadata.SECTION_START_ABSOLUTE_TIME" +// PlatformBridgeApis.MediaMetadataKey.sectionStartTimeInContainer -> "com.google.android.gms.cast.metadata.SECTION_START_TIME_IN_CONTAINER" +// PlatformBridgeApis.MediaMetadataKey.sectionStartTimeInMedia -> "com.google.android.gms.cast.metadata.SECTION_START_TIME_IN_MEDIA" +// PlatformBridgeApis.MediaMetadataKey.seriesTitle -> "com.google.android.gms.cast.metadata.SERIES_TITLE" +// PlatformBridgeApis.MediaMetadataKey.studio -> "com.google.android.gms.cast.metadata.STUDIO" +// PlatformBridgeApis.MediaMetadataKey.subtitle -> "com.google.android.gms.cast.metadata.SUBTITLE" +// PlatformBridgeApis.MediaMetadataKey.title -> "com.google.android.gms.cast.metadata.TITLE" +// PlatformBridgeApis.MediaMetadataKey.trackNumber -> "com.google.android.gms.cast.metadata.TRACK_NUMBER" +// PlatformBridgeApis.MediaMetadataKey.width -> "com.google.android.gms.cast.metadata.WIDTH" +// } +//} fun getMediaTrack(mediaTrack: PlatformBridgeApis.MediaTrack) : MediaTrack { val trackType = getTrackType(mediaTrack.trackType) diff --git a/ios/Classes/PlatformBridgeApis.h b/ios/Classes/PlatformBridgeApis.h index 69e3067..348289b 100644 --- a/ios/Classes/PlatformBridgeApis.h +++ b/ios/Classes/PlatformBridgeApis.h @@ -25,37 +25,6 @@ typedef NS_ENUM(NSUInteger, MediaType) { MediaTypeUser = 6, }; -typedef NS_ENUM(NSUInteger, MediaMetadataKey) { - MediaMetadataKeyAlbumArtist = 0, - MediaMetadataKeyAlbumTitle = 1, - MediaMetadataKeyArtist = 2, - MediaMetadataKeyBookTitle = 3, - MediaMetadataKeyBroadcastDate = 4, - MediaMetadataKeyChapterNumber = 5, - MediaMetadataKeyChapterTitle = 6, - MediaMetadataKeyComposer = 7, - MediaMetadataKeyCreationDate = 8, - MediaMetadataKeyDiscNumber = 9, - MediaMetadataKeyEpisodeNumber = 10, - MediaMetadataKeyHeight = 11, - MediaMetadataKeyLocationLatitude = 12, - MediaMetadataKeyLocationLongitude = 13, - MediaMetadataKeyLocationName = 14, - MediaMetadataKeyQueueItemId = 15, - MediaMetadataKeyReleaseDate = 16, - MediaMetadataKeySeasonNumber = 17, - MediaMetadataKeySectionDuration = 18, - MediaMetadataKeySectionStartAbsoluteTime = 19, - MediaMetadataKeySectionStartTimeInContainer = 20, - MediaMetadataKeySectionStartTimeInMedia = 21, - MediaMetadataKeySeriesTitle = 22, - MediaMetadataKeyStudio = 23, - MediaMetadataKeySubtitle = 24, - MediaMetadataKeyTitle = 25, - MediaMetadataKeyTrackNumber = 26, - MediaMetadataKeyWidth = 27, -}; - typedef NS_ENUM(NSUInteger, TrackType) { TrackTypeUnknown = 0, TrackTypeText = 1, @@ -98,7 +67,6 @@ typedef NS_ENUM(NSUInteger, TrackSubtype) { @interface MediaMetadata : NSObject @property(nonatomic, assign) MediaType mediaType; -@property(nonatomic, strong, nullable) NSDictionary * strings; @property(nonatomic, strong, nullable) NSArray * webImages; @end diff --git a/ios/Classes/PlatformBridgeApis.m b/ios/Classes/PlatformBridgeApis.m index 2015d43..9ea6f1c 100644 --- a/ios/Classes/PlatformBridgeApis.m +++ b/ios/Classes/PlatformBridgeApis.m @@ -108,10 +108,6 @@ static NSDictionary *wrapResult(id result, FlutterError *error) + (MediaMetadata *)fromMap:(NSDictionary *)dict { MediaMetadata *result = [[MediaMetadata alloc] init]; result.mediaType = [dict[@"mediaType"] integerValue]; - result.strings = dict[@"strings"]; - if ((NSNull *)result.strings == [NSNull null]) { - result.strings = nil; - } result.webImages = dict[@"webImages"]; if ((NSNull *)result.webImages == [NSNull null]) { result.webImages = nil; @@ -119,7 +115,7 @@ static NSDictionary *wrapResult(id result, FlutterError *error) return result; } - (NSDictionary *)toMap { - return [NSDictionary dictionaryWithObjectsAndKeys:@(self.mediaType), @"mediaType", (self.strings ? self.strings : [NSNull null]), @"strings", (self.webImages ? self.webImages : [NSNull null]), @"webImages", nil]; + return [NSDictionary dictionaryWithObjectsAndKeys:@(self.mediaType), @"mediaType", (self.webImages ? self.webImages : [NSNull null]), @"webImages", nil]; } @end diff --git a/ios/Classes/SwiftFlutterCastFrameworkPlugin.swift b/ios/Classes/SwiftFlutterCastFrameworkPlugin.swift index e03cf93..3086c2b 100644 --- a/ios/Classes/SwiftFlutterCastFrameworkPlugin.swift +++ b/ios/Classes/SwiftFlutterCastFrameworkPlugin.swift @@ -128,6 +128,10 @@ public class SwiftFlutterCastFrameworkPlugin: NSObject, FlutterPlugin, GCKSessio castContext.presentCastDialog() } + public func loadMediaLoadRequestDataRequest(_ request: MediaLoadRequestData, error: AutoreleasingUnsafeMutablePointer) { + // TODO + } + // MARK: - GCKSessionManagerListener // onSessionSuspended diff --git a/lib/src/PlatformBridgeApis.dart b/lib/src/PlatformBridgeApis.dart index 880dcd5..cea3f45 100644 --- a/lib/src/PlatformBridgeApis.dart +++ b/lib/src/PlatformBridgeApis.dart @@ -25,37 +25,6 @@ enum MediaType { user, } -enum MediaMetadataKey { - albumArtist, - albumTitle, - artist, - bookTitle, - broadcastDate, - chapterNumber, - chapterTitle, - composer, - creationDate, - discNumber, - episodeNumber, - height, - locationLatitude, - locationLongitude, - locationName, - queueItemId, - releaseDate, - seasonNumber, - sectionDuration, - sectionStartAbsoluteTime, - sectionStartTimeInContainer, - sectionStartTimeInMedia, - seriesTitle, - studio, - subtitle, - title, - trackNumber, - width, -} - enum TrackType { unknown, text, @@ -137,13 +106,11 @@ class MediaInfo { class MediaMetadata { MediaType? mediaType; - Map? strings; List? webImages; Object encode() { final Map pigeonMap = {}; pigeonMap['mediaType'] = mediaType == null ? null : mediaType!.index; - pigeonMap['strings'] = strings; pigeonMap['webImages'] = webImages; return pigeonMap; } @@ -154,7 +121,6 @@ class MediaMetadata { ..mediaType = pigeonMap['mediaType'] != null ? MediaType.values[pigeonMap['mediaType']! as int] : null - ..strings = (pigeonMap['strings'] as Map?)?.cast() ..webImages = (pigeonMap['webImages'] as List?)?.cast(); } } diff --git a/lib/src/PlatformBridgeApisDefinition.dart b/lib/src/PlatformBridgeApisDefinition.dart index f8e1c4f..548d9ce 100644 --- a/lib/src/PlatformBridgeApisDefinition.dart +++ b/lib/src/PlatformBridgeApisDefinition.dart @@ -41,7 +41,7 @@ enum StreamType { /// Docs here: https://developers.google.com/android/reference/com/google/android/gms/cast/MediaMetadata class MediaMetadata { MediaType? mediaType; - Map? strings; + // Map? strings; // Can't uncomment this because of https://github.com/flutter/flutter/issues/93525 List? webImages; }