MediaStatus handling pigeon
This commit is contained in:
parent
3ae88ceb8a
commit
1b4e5ac33b
5 changed files with 406 additions and 23 deletions
|
|
@ -73,6 +73,20 @@ public class PlatformBridgeApis {
|
|||
}
|
||||
}
|
||||
|
||||
public enum PlayerState {
|
||||
unknown(0),
|
||||
idle(1),
|
||||
playing(2),
|
||||
paused(3),
|
||||
buffering(4),
|
||||
loading(5);
|
||||
|
||||
private int index;
|
||||
private PlayerState(final int index) {
|
||||
this.index = index;
|
||||
}
|
||||
}
|
||||
|
||||
/** Generated class from Pigeon that represents data sent in messages. */
|
||||
public static class MediaLoadRequestData {
|
||||
private Boolean shouldAutoplay;
|
||||
|
|
@ -266,6 +280,79 @@ public class PlatformBridgeApis {
|
|||
}
|
||||
}
|
||||
|
||||
/** Generated class from Pigeon that represents data sent in messages. */
|
||||
public static class MediaStatus {
|
||||
private PlayerState playerState;
|
||||
public PlayerState getPlayerState() { return playerState; }
|
||||
public void setPlayerState(PlayerState setterArg) { this.playerState = setterArg; }
|
||||
|
||||
private Boolean isPlayingAd;
|
||||
public Boolean getIsPlayingAd() { return isPlayingAd; }
|
||||
public void setIsPlayingAd(Boolean setterArg) { this.isPlayingAd = setterArg; }
|
||||
|
||||
private MediaInfo mediaInfo;
|
||||
public MediaInfo getMediaInfo() { return mediaInfo; }
|
||||
public void setMediaInfo(MediaInfo setterArg) { this.mediaInfo = setterArg; }
|
||||
|
||||
private AdBreakStatus adBreakStatus;
|
||||
public AdBreakStatus getAdBreakStatus() { return adBreakStatus; }
|
||||
public void setAdBreakStatus(AdBreakStatus setterArg) { this.adBreakStatus = setterArg; }
|
||||
|
||||
Map<String, Object> toMap() {
|
||||
Map<String, Object> toMapResult = new HashMap<>();
|
||||
toMapResult.put("playerState", playerState.index);
|
||||
toMapResult.put("isPlayingAd", isPlayingAd);
|
||||
toMapResult.put("mediaInfo", (mediaInfo == null) ? null : mediaInfo.toMap());
|
||||
toMapResult.put("adBreakStatus", (adBreakStatus == null) ? null : adBreakStatus.toMap());
|
||||
return toMapResult;
|
||||
}
|
||||
static MediaStatus fromMap(Map<String, Object> map) {
|
||||
MediaStatus fromMapResult = new MediaStatus();
|
||||
Object playerState = map.get("playerState");
|
||||
fromMapResult.playerState = PlayerState.values()[(int)playerState];
|
||||
Object isPlayingAd = map.get("isPlayingAd");
|
||||
fromMapResult.isPlayingAd = (Boolean)isPlayingAd;
|
||||
Object mediaInfo = map.get("mediaInfo");
|
||||
fromMapResult.mediaInfo = MediaInfo.fromMap((Map)mediaInfo);
|
||||
Object adBreakStatus = map.get("adBreakStatus");
|
||||
fromMapResult.adBreakStatus = AdBreakStatus.fromMap((Map)adBreakStatus);
|
||||
return fromMapResult;
|
||||
}
|
||||
}
|
||||
|
||||
/** Generated class from Pigeon that represents data sent in messages. */
|
||||
public static class AdBreakStatus {
|
||||
private String adBreakId;
|
||||
public String getAdBreakId() { return adBreakId; }
|
||||
public void setAdBreakId(String setterArg) { this.adBreakId = setterArg; }
|
||||
|
||||
private String adBreakClipId;
|
||||
public String getAdBreakClipId() { return adBreakClipId; }
|
||||
public void setAdBreakClipId(String setterArg) { this.adBreakClipId = setterArg; }
|
||||
|
||||
private Long whenSkippableMs;
|
||||
public Long getWhenSkippableMs() { return whenSkippableMs; }
|
||||
public void setWhenSkippableMs(Long setterArg) { this.whenSkippableMs = setterArg; }
|
||||
|
||||
Map<String, Object> toMap() {
|
||||
Map<String, Object> toMapResult = new HashMap<>();
|
||||
toMapResult.put("adBreakId", adBreakId);
|
||||
toMapResult.put("adBreakClipId", adBreakClipId);
|
||||
toMapResult.put("whenSkippableMs", whenSkippableMs);
|
||||
return toMapResult;
|
||||
}
|
||||
static AdBreakStatus fromMap(Map<String, Object> map) {
|
||||
AdBreakStatus fromMapResult = new AdBreakStatus();
|
||||
Object adBreakId = map.get("adBreakId");
|
||||
fromMapResult.adBreakId = (String)adBreakId;
|
||||
Object adBreakClipId = map.get("adBreakClipId");
|
||||
fromMapResult.adBreakClipId = (String)adBreakClipId;
|
||||
Object whenSkippableMs = map.get("whenSkippableMs");
|
||||
fromMapResult.whenSkippableMs = (whenSkippableMs == null) ? null : ((whenSkippableMs instanceof Integer) ? (Integer)whenSkippableMs : (Long)whenSkippableMs);
|
||||
return fromMapResult;
|
||||
}
|
||||
}
|
||||
|
||||
/** Generated class from Pigeon that represents data sent in messages. */
|
||||
public static class CastDevice {
|
||||
private String deviceId;
|
||||
|
|
@ -626,8 +713,26 @@ public class PlatformBridgeApis {
|
|||
protected Object readValueOfType(byte type, ByteBuffer buffer) {
|
||||
switch (type) {
|
||||
case (byte)128:
|
||||
return AdBreakStatus.fromMap((Map<String, Object>) readValue(buffer));
|
||||
|
||||
case (byte)129:
|
||||
return CastMessage.fromMap((Map<String, Object>) readValue(buffer));
|
||||
|
||||
case (byte)130:
|
||||
return MediaInfo.fromMap((Map<String, Object>) readValue(buffer));
|
||||
|
||||
case (byte)131:
|
||||
return MediaMetadata.fromMap((Map<String, Object>) readValue(buffer));
|
||||
|
||||
case (byte)132:
|
||||
return MediaStatus.fromMap((Map<String, Object>) readValue(buffer));
|
||||
|
||||
case (byte)133:
|
||||
return MediaTrack.fromMap((Map<String, Object>) readValue(buffer));
|
||||
|
||||
case (byte)134:
|
||||
return WebImage.fromMap((Map<String, Object>) readValue(buffer));
|
||||
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
|
||||
|
|
@ -635,10 +740,34 @@ public class PlatformBridgeApis {
|
|||
}
|
||||
@Override
|
||||
protected void writeValue(ByteArrayOutputStream stream, Object value) {
|
||||
if (value instanceof CastMessage) {
|
||||
if (value instanceof AdBreakStatus) {
|
||||
stream.write(128);
|
||||
writeValue(stream, ((AdBreakStatus) value).toMap());
|
||||
} else
|
||||
if (value instanceof CastMessage) {
|
||||
stream.write(129);
|
||||
writeValue(stream, ((CastMessage) value).toMap());
|
||||
} else
|
||||
if (value instanceof MediaInfo) {
|
||||
stream.write(130);
|
||||
writeValue(stream, ((MediaInfo) value).toMap());
|
||||
} else
|
||||
if (value instanceof MediaMetadata) {
|
||||
stream.write(131);
|
||||
writeValue(stream, ((MediaMetadata) value).toMap());
|
||||
} else
|
||||
if (value instanceof MediaStatus) {
|
||||
stream.write(132);
|
||||
writeValue(stream, ((MediaStatus) value).toMap());
|
||||
} else
|
||||
if (value instanceof MediaTrack) {
|
||||
stream.write(133);
|
||||
writeValue(stream, ((MediaTrack) value).toMap());
|
||||
} else
|
||||
if (value instanceof WebImage) {
|
||||
stream.write(134);
|
||||
writeValue(stream, ((WebImage) value).toMap());
|
||||
} else
|
||||
{
|
||||
super.writeValue(stream, value);
|
||||
}
|
||||
|
|
@ -744,10 +873,10 @@ public class PlatformBridgeApis {
|
|||
callback.reply(null);
|
||||
});
|
||||
}
|
||||
public void onStatusUpdated(Long playerStateRawArg, Reply<Void> callback) {
|
||||
public void onStatusUpdated(MediaStatus mediaStatusArg, Reply<Void> callback) {
|
||||
BasicMessageChannel<Object> channel =
|
||||
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CastFlutterApi.onStatusUpdated", getCodec());
|
||||
channel.send(new ArrayList<Object>(Arrays.asList(playerStateRawArg)), channelReply -> {
|
||||
channel.send(new ArrayList<Object>(Arrays.asList(mediaStatusArg)), channelReply -> {
|
||||
callback.reply(null);
|
||||
});
|
||||
}
|
||||
|
|
@ -779,10 +908,10 @@ public class PlatformBridgeApis {
|
|||
callback.reply(null);
|
||||
});
|
||||
}
|
||||
public void onAdBreakStatusUpdated(Reply<Void> callback) {
|
||||
public void onAdBreakStatusUpdated(MediaStatus mediaStatusArg, Reply<Void> callback) {
|
||||
BasicMessageChannel<Object> channel =
|
||||
new BasicMessageChannel<>(binaryMessenger, "dev.flutter.pigeon.CastFlutterApi.onAdBreakStatusUpdated", getCodec());
|
||||
channel.send(null, channelReply -> {
|
||||
channel.send(new ArrayList<Object>(Arrays.asList(mediaStatusArg)), channelReply -> {
|
||||
callback.reply(null);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,11 +42,22 @@ typedef NS_ENUM(NSUInteger, TrackSubtype) {
|
|||
TrackSubtypeMetadata = 6,
|
||||
};
|
||||
|
||||
typedef NS_ENUM(NSUInteger, PlayerState) {
|
||||
PlayerStateUnknown = 0,
|
||||
PlayerStateIdle = 1,
|
||||
PlayerStatePlaying = 2,
|
||||
PlayerStatePaused = 3,
|
||||
PlayerStateBuffering = 4,
|
||||
PlayerStateLoading = 5,
|
||||
};
|
||||
|
||||
@class MediaLoadRequestData;
|
||||
@class MediaInfo;
|
||||
@class MediaMetadata;
|
||||
@class WebImage;
|
||||
@class MediaTrack;
|
||||
@class MediaStatus;
|
||||
@class AdBreakStatus;
|
||||
@class CastDevice;
|
||||
@class CastMessage;
|
||||
|
||||
|
|
@ -84,6 +95,19 @@ typedef NS_ENUM(NSUInteger, TrackSubtype) {
|
|||
@property(nonatomic, copy, nullable) NSString * language;
|
||||
@end
|
||||
|
||||
@interface MediaStatus : NSObject
|
||||
@property(nonatomic, assign) PlayerState playerState;
|
||||
@property(nonatomic, strong, nullable) NSNumber * isPlayingAd;
|
||||
@property(nonatomic, strong, nullable) MediaInfo * mediaInfo;
|
||||
@property(nonatomic, strong, nullable) AdBreakStatus * adBreakStatus;
|
||||
@end
|
||||
|
||||
@interface AdBreakStatus : NSObject
|
||||
@property(nonatomic, copy, nullable) NSString * adBreakId;
|
||||
@property(nonatomic, copy, nullable) NSString * adBreakClipId;
|
||||
@property(nonatomic, strong, nullable) NSNumber * whenSkippableMs;
|
||||
@end
|
||||
|
||||
@interface CastDevice : NSObject
|
||||
@property(nonatomic, copy, nullable) NSString * deviceId;
|
||||
@property(nonatomic, copy, nullable) NSString * friendlyName;
|
||||
|
|
@ -130,12 +154,12 @@ NSObject<FlutterMessageCodec> *CastFlutterApiGetCodec(void);
|
|||
- (void)onSessionResumedWithCompletion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onSessionResumeFailedWithCompletion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onSessionSuspendedWithCompletion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onStatusUpdatedPlayerStateRaw:(NSNumber *)playerStateRaw completion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onStatusUpdatedMediaStatus:(MediaStatus *)mediaStatus completion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onMetadataUpdatedWithCompletion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onQueueStatusUpdatedWithCompletion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onPreloadStatusUpdatedWithCompletion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onSendingRemoteMediaRequestWithCompletion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onAdBreakStatusUpdatedWithCompletion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onAdBreakStatusUpdatedMediaStatus:(MediaStatus *)mediaStatus completion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onMediaErrorWithCompletion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onProgressUpdatedProgressMs:(NSNumber *)progressMs durationMs:(NSNumber *)durationMs completion:(void(^)(NSError *_Nullable))completion;
|
||||
- (void)onAdBreakClipProgressUpdatedAdBreakId:(NSString *)adBreakId adBreakClipId:(NSString *)adBreakClipId progressMs:(NSNumber *)progressMs durationMs:(NSNumber *)durationMs whenSkippableMs:(NSNumber *)whenSkippableMs completion:(void(^)(NSError *_Nullable))completion;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,14 @@ static NSDictionary<NSString *, id> *wrapResult(id result, FlutterError *error)
|
|||
+ (MediaTrack *)fromMap:(NSDictionary *)dict;
|
||||
- (NSDictionary *)toMap;
|
||||
@end
|
||||
@interface MediaStatus ()
|
||||
+ (MediaStatus *)fromMap:(NSDictionary *)dict;
|
||||
- (NSDictionary *)toMap;
|
||||
@end
|
||||
@interface AdBreakStatus ()
|
||||
+ (AdBreakStatus *)fromMap:(NSDictionary *)dict;
|
||||
- (NSDictionary *)toMap;
|
||||
@end
|
||||
@interface CastDevice ()
|
||||
+ (CastDevice *)fromMap:(NSDictionary *)dict;
|
||||
- (NSDictionary *)toMap;
|
||||
|
|
@ -165,6 +173,51 @@ static NSDictionary<NSString *, id> *wrapResult(id result, FlutterError *error)
|
|||
}
|
||||
@end
|
||||
|
||||
@implementation MediaStatus
|
||||
+ (MediaStatus *)fromMap:(NSDictionary *)dict {
|
||||
MediaStatus *result = [[MediaStatus alloc] init];
|
||||
result.playerState = [dict[@"playerState"] integerValue];
|
||||
result.isPlayingAd = dict[@"isPlayingAd"];
|
||||
if ((NSNull *)result.isPlayingAd == [NSNull null]) {
|
||||
result.isPlayingAd = nil;
|
||||
}
|
||||
result.mediaInfo = [MediaInfo fromMap:dict[@"mediaInfo"]];
|
||||
if ((NSNull *)result.mediaInfo == [NSNull null]) {
|
||||
result.mediaInfo = nil;
|
||||
}
|
||||
result.adBreakStatus = [AdBreakStatus fromMap:dict[@"adBreakStatus"]];
|
||||
if ((NSNull *)result.adBreakStatus == [NSNull null]) {
|
||||
result.adBreakStatus = nil;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
- (NSDictionary *)toMap {
|
||||
return [NSDictionary dictionaryWithObjectsAndKeys:@(self.playerState), @"playerState", (self.isPlayingAd ? self.isPlayingAd : [NSNull null]), @"isPlayingAd", (self.mediaInfo ? [self.mediaInfo toMap] : [NSNull null]), @"mediaInfo", (self.adBreakStatus ? [self.adBreakStatus toMap] : [NSNull null]), @"adBreakStatus", nil];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation AdBreakStatus
|
||||
+ (AdBreakStatus *)fromMap:(NSDictionary *)dict {
|
||||
AdBreakStatus *result = [[AdBreakStatus alloc] init];
|
||||
result.adBreakId = dict[@"adBreakId"];
|
||||
if ((NSNull *)result.adBreakId == [NSNull null]) {
|
||||
result.adBreakId = nil;
|
||||
}
|
||||
result.adBreakClipId = dict[@"adBreakClipId"];
|
||||
if ((NSNull *)result.adBreakClipId == [NSNull null]) {
|
||||
result.adBreakClipId = nil;
|
||||
}
|
||||
result.whenSkippableMs = dict[@"whenSkippableMs"];
|
||||
if ((NSNull *)result.whenSkippableMs == [NSNull null]) {
|
||||
result.whenSkippableMs = nil;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
- (NSDictionary *)toMap {
|
||||
return [NSDictionary dictionaryWithObjectsAndKeys:(self.adBreakId ? self.adBreakId : [NSNull null]), @"adBreakId", (self.adBreakClipId ? self.adBreakClipId : [NSNull null]), @"adBreakClipId", (self.whenSkippableMs ? self.whenSkippableMs : [NSNull null]), @"whenSkippableMs", nil];
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation CastDevice
|
||||
+ (CastDevice *)fromMap:(NSDictionary *)dict {
|
||||
CastDevice *result = [[CastDevice alloc] init];
|
||||
|
|
@ -495,8 +548,26 @@ void CastHostApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<CastH
|
|||
{
|
||||
switch (type) {
|
||||
case 128:
|
||||
return [AdBreakStatus fromMap:[self readValue]];
|
||||
|
||||
case 129:
|
||||
return [CastMessage fromMap:[self readValue]];
|
||||
|
||||
case 130:
|
||||
return [MediaInfo fromMap:[self readValue]];
|
||||
|
||||
case 131:
|
||||
return [MediaMetadata fromMap:[self readValue]];
|
||||
|
||||
case 132:
|
||||
return [MediaStatus fromMap:[self readValue]];
|
||||
|
||||
case 133:
|
||||
return [MediaTrack fromMap:[self readValue]];
|
||||
|
||||
case 134:
|
||||
return [WebImage fromMap:[self readValue]];
|
||||
|
||||
default:
|
||||
return [super readValueOfType:type];
|
||||
|
||||
|
|
@ -509,10 +580,34 @@ void CastHostApiSetup(id<FlutterBinaryMessenger> binaryMessenger, NSObject<CastH
|
|||
@implementation CastFlutterApiCodecWriter
|
||||
- (void)writeValue:(id)value
|
||||
{
|
||||
if ([value isKindOfClass:[CastMessage class]]) {
|
||||
if ([value isKindOfClass:[AdBreakStatus class]]) {
|
||||
[self writeByte:128];
|
||||
[self writeValue:[value toMap]];
|
||||
} else
|
||||
if ([value isKindOfClass:[CastMessage class]]) {
|
||||
[self writeByte:129];
|
||||
[self writeValue:[value toMap]];
|
||||
} else
|
||||
if ([value isKindOfClass:[MediaInfo class]]) {
|
||||
[self writeByte:130];
|
||||
[self writeValue:[value toMap]];
|
||||
} else
|
||||
if ([value isKindOfClass:[MediaMetadata class]]) {
|
||||
[self writeByte:131];
|
||||
[self writeValue:[value toMap]];
|
||||
} else
|
||||
if ([value isKindOfClass:[MediaStatus class]]) {
|
||||
[self writeByte:132];
|
||||
[self writeValue:[value toMap]];
|
||||
} else
|
||||
if ([value isKindOfClass:[MediaTrack class]]) {
|
||||
[self writeByte:133];
|
||||
[self writeValue:[value toMap]];
|
||||
} else
|
||||
if ([value isKindOfClass:[WebImage class]]) {
|
||||
[self writeByte:134];
|
||||
[self writeValue:[value toMap]];
|
||||
} else
|
||||
{
|
||||
[super writeValue:value];
|
||||
}
|
||||
|
|
@ -675,13 +770,13 @@ NSObject<FlutterMessageCodec> *CastFlutterApiGetCodec() {
|
|||
completion(nil);
|
||||
}];
|
||||
}
|
||||
- (void)onStatusUpdatedPlayerStateRaw:(NSNumber *)arg_playerStateRaw completion:(void(^)(NSError *_Nullable))completion {
|
||||
- (void)onStatusUpdatedMediaStatus:(MediaStatus *)arg_mediaStatus completion:(void(^)(NSError *_Nullable))completion {
|
||||
FlutterBasicMessageChannel *channel =
|
||||
[FlutterBasicMessageChannel
|
||||
messageChannelWithName:@"dev.flutter.pigeon.CastFlutterApi.onStatusUpdated"
|
||||
binaryMessenger:self.binaryMessenger
|
||||
codec:CastFlutterApiGetCodec()];
|
||||
[channel sendMessage:@[arg_playerStateRaw] reply:^(id reply) {
|
||||
[channel sendMessage:@[arg_mediaStatus] reply:^(id reply) {
|
||||
completion(nil);
|
||||
}];
|
||||
}
|
||||
|
|
@ -725,13 +820,13 @@ NSObject<FlutterMessageCodec> *CastFlutterApiGetCodec() {
|
|||
completion(nil);
|
||||
}];
|
||||
}
|
||||
- (void)onAdBreakStatusUpdatedWithCompletion:(void(^)(NSError *_Nullable))completion {
|
||||
- (void)onAdBreakStatusUpdatedMediaStatus:(MediaStatus *)arg_mediaStatus completion:(void(^)(NSError *_Nullable))completion {
|
||||
FlutterBasicMessageChannel *channel =
|
||||
[FlutterBasicMessageChannel
|
||||
messageChannelWithName:@"dev.flutter.pigeon.CastFlutterApi.onAdBreakStatusUpdated"
|
||||
binaryMessenger:self.binaryMessenger
|
||||
codec:CastFlutterApiGetCodec()];
|
||||
[channel sendMessage:nil reply:^(id reply) {
|
||||
[channel sendMessage:@[arg_mediaStatus] reply:^(id reply) {
|
||||
completion(nil);
|
||||
}];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,15 @@ enum TrackSubtype {
|
|||
metadata,
|
||||
}
|
||||
|
||||
enum PlayerState {
|
||||
unknown,
|
||||
idle,
|
||||
playing,
|
||||
paused,
|
||||
buffering,
|
||||
loading,
|
||||
}
|
||||
|
||||
class MediaLoadRequestData {
|
||||
bool? shouldAutoplay;
|
||||
int? currentTime;
|
||||
|
|
@ -176,6 +185,59 @@ class MediaTrack {
|
|||
}
|
||||
}
|
||||
|
||||
class MediaStatus {
|
||||
PlayerState? playerState;
|
||||
bool? isPlayingAd;
|
||||
MediaInfo? mediaInfo;
|
||||
AdBreakStatus? adBreakStatus;
|
||||
|
||||
Object encode() {
|
||||
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
|
||||
pigeonMap['playerState'] = playerState == null ? null : playerState!.index;
|
||||
pigeonMap['isPlayingAd'] = isPlayingAd;
|
||||
pigeonMap['mediaInfo'] = mediaInfo == null ? null : mediaInfo!.encode();
|
||||
pigeonMap['adBreakStatus'] = adBreakStatus == null ? null : adBreakStatus!.encode();
|
||||
return pigeonMap;
|
||||
}
|
||||
|
||||
static MediaStatus decode(Object message) {
|
||||
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
|
||||
return MediaStatus()
|
||||
..playerState = pigeonMap['playerState'] != null
|
||||
? PlayerState.values[pigeonMap['playerState']! as int]
|
||||
: null
|
||||
..isPlayingAd = pigeonMap['isPlayingAd'] as bool?
|
||||
..mediaInfo = pigeonMap['mediaInfo'] != null
|
||||
? MediaInfo.decode(pigeonMap['mediaInfo']!)
|
||||
: null
|
||||
..adBreakStatus = pigeonMap['adBreakStatus'] != null
|
||||
? AdBreakStatus.decode(pigeonMap['adBreakStatus']!)
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
class AdBreakStatus {
|
||||
String? adBreakId;
|
||||
String? adBreakClipId;
|
||||
int? whenSkippableMs;
|
||||
|
||||
Object encode() {
|
||||
final Map<Object?, Object?> pigeonMap = <Object?, Object?>{};
|
||||
pigeonMap['adBreakId'] = adBreakId;
|
||||
pigeonMap['adBreakClipId'] = adBreakClipId;
|
||||
pigeonMap['whenSkippableMs'] = whenSkippableMs;
|
||||
return pigeonMap;
|
||||
}
|
||||
|
||||
static AdBreakStatus decode(Object message) {
|
||||
final Map<Object?, Object?> pigeonMap = message as Map<Object?, Object?>;
|
||||
return AdBreakStatus()
|
||||
..adBreakId = pigeonMap['adBreakId'] as String?
|
||||
..adBreakClipId = pigeonMap['adBreakClipId'] as String?
|
||||
..whenSkippableMs = pigeonMap['whenSkippableMs'] as int?;
|
||||
}
|
||||
}
|
||||
|
||||
class CastDevice {
|
||||
String? deviceId;
|
||||
String? friendlyName;
|
||||
|
|
@ -529,10 +591,34 @@ class _CastFlutterApiCodec extends StandardMessageCodec {
|
|||
const _CastFlutterApiCodec();
|
||||
@override
|
||||
void writeValue(WriteBuffer buffer, Object? value) {
|
||||
if (value is CastMessage) {
|
||||
if (value is AdBreakStatus) {
|
||||
buffer.putUint8(128);
|
||||
writeValue(buffer, value.encode());
|
||||
} else
|
||||
if (value is CastMessage) {
|
||||
buffer.putUint8(129);
|
||||
writeValue(buffer, value.encode());
|
||||
} else
|
||||
if (value is MediaInfo) {
|
||||
buffer.putUint8(130);
|
||||
writeValue(buffer, value.encode());
|
||||
} else
|
||||
if (value is MediaMetadata) {
|
||||
buffer.putUint8(131);
|
||||
writeValue(buffer, value.encode());
|
||||
} else
|
||||
if (value is MediaStatus) {
|
||||
buffer.putUint8(132);
|
||||
writeValue(buffer, value.encode());
|
||||
} else
|
||||
if (value is MediaTrack) {
|
||||
buffer.putUint8(133);
|
||||
writeValue(buffer, value.encode());
|
||||
} else
|
||||
if (value is WebImage) {
|
||||
buffer.putUint8(134);
|
||||
writeValue(buffer, value.encode());
|
||||
} else
|
||||
{
|
||||
super.writeValue(buffer, value);
|
||||
}
|
||||
|
|
@ -541,8 +627,26 @@ class _CastFlutterApiCodec extends StandardMessageCodec {
|
|||
Object? readValueOfType(int type, ReadBuffer buffer) {
|
||||
switch (type) {
|
||||
case 128:
|
||||
return AdBreakStatus.decode(readValue(buffer)!);
|
||||
|
||||
case 129:
|
||||
return CastMessage.decode(readValue(buffer)!);
|
||||
|
||||
case 130:
|
||||
return MediaInfo.decode(readValue(buffer)!);
|
||||
|
||||
case 131:
|
||||
return MediaMetadata.decode(readValue(buffer)!);
|
||||
|
||||
case 132:
|
||||
return MediaStatus.decode(readValue(buffer)!);
|
||||
|
||||
case 133:
|
||||
return MediaTrack.decode(readValue(buffer)!);
|
||||
|
||||
case 134:
|
||||
return WebImage.decode(readValue(buffer)!);
|
||||
|
||||
default:
|
||||
return super.readValueOfType(type, buffer);
|
||||
|
||||
|
|
@ -564,12 +668,12 @@ abstract class CastFlutterApi {
|
|||
void onSessionResumed();
|
||||
void onSessionResumeFailed();
|
||||
void onSessionSuspended();
|
||||
void onStatusUpdated(int playerStateRaw);
|
||||
void onStatusUpdated(MediaStatus mediaStatus);
|
||||
void onMetadataUpdated();
|
||||
void onQueueStatusUpdated();
|
||||
void onPreloadStatusUpdated();
|
||||
void onSendingRemoteMediaRequest();
|
||||
void onAdBreakStatusUpdated();
|
||||
void onAdBreakStatusUpdated(MediaStatus mediaStatus);
|
||||
void onMediaError();
|
||||
void onProgressUpdated(int progressMs, int durationMs);
|
||||
void onAdBreakClipProgressUpdated(String adBreakId, String adBreakClipId, int progressMs, int durationMs, int whenSkippableMs);
|
||||
|
|
@ -745,9 +849,9 @@ abstract class CastFlutterApi {
|
|||
channel.setMessageHandler((Object? message) async {
|
||||
assert(message != null, 'Argument for dev.flutter.pigeon.CastFlutterApi.onStatusUpdated was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final int? arg_playerStateRaw = args[0] as int?;
|
||||
assert(arg_playerStateRaw != null, 'Argument for dev.flutter.pigeon.CastFlutterApi.onStatusUpdated was null, expected non-null int.');
|
||||
api.onStatusUpdated(arg_playerStateRaw!);
|
||||
final MediaStatus? arg_mediaStatus = args[0] as MediaStatus?;
|
||||
assert(arg_mediaStatus != null, 'Argument for dev.flutter.pigeon.CastFlutterApi.onStatusUpdated was null, expected non-null MediaStatus.');
|
||||
api.onStatusUpdated(arg_mediaStatus!);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
|
@ -811,8 +915,11 @@ abstract class CastFlutterApi {
|
|||
channel.setMessageHandler(null);
|
||||
} else {
|
||||
channel.setMessageHandler((Object? message) async {
|
||||
// ignore message
|
||||
api.onAdBreakStatusUpdated();
|
||||
assert(message != null, 'Argument for dev.flutter.pigeon.CastFlutterApi.onAdBreakStatusUpdated was null.');
|
||||
final List<Object?> args = (message as List<Object?>?)!;
|
||||
final MediaStatus? arg_mediaStatus = args[0] as MediaStatus?;
|
||||
assert(arg_mediaStatus != null, 'Argument for dev.flutter.pigeon.CastFlutterApi.onAdBreakStatusUpdated was null, expected non-null MediaStatus.');
|
||||
api.onAdBreakStatusUpdated(arg_mediaStatus!);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -210,6 +210,35 @@ enum TrackSubtype {
|
|||
metadata,
|
||||
}
|
||||
|
||||
/// State of the remote media player
|
||||
enum PlayerState {
|
||||
/// Constant indicating unknown player state.
|
||||
unknown, // 0
|
||||
/// Constant indicating that the media player is idle.
|
||||
idle, // 1
|
||||
/// Constant indicating that the media player is playing.
|
||||
playing, // 2
|
||||
/// Constant indicating that the media player is paused.
|
||||
paused, // 3
|
||||
/// Constant indicating that the media player is buffering.
|
||||
buffering, // 4
|
||||
/// Constant indicating that the media player is loading.
|
||||
loading, // 5
|
||||
}
|
||||
|
||||
class MediaStatus {
|
||||
PlayerState? playerState;
|
||||
bool? isPlayingAd;
|
||||
MediaInfo? mediaInfo;
|
||||
AdBreakStatus? adBreakStatus;
|
||||
}
|
||||
|
||||
class AdBreakStatus {
|
||||
String? adBreakId;
|
||||
String? adBreakClipId;
|
||||
int? whenSkippableMs;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
class CastDevice {
|
||||
|
|
@ -261,13 +290,12 @@ abstract class CastFlutterApi {
|
|||
//endregion
|
||||
|
||||
//region RemoteMediaClient callbacks
|
||||
// I can't use enum here because of: https://github.com/flutter/flutter/issues/87307
|
||||
void onStatusUpdated(int playerStateRaw);
|
||||
void onStatusUpdated(MediaStatus mediaStatus);
|
||||
void onMetadataUpdated();
|
||||
void onQueueStatusUpdated();
|
||||
void onPreloadStatusUpdated();
|
||||
void onSendingRemoteMediaRequest();
|
||||
void onAdBreakStatusUpdated();
|
||||
void onAdBreakStatusUpdated(MediaStatus mediaStatus);
|
||||
void onMediaError();
|
||||
|
||||
void onProgressUpdated(int progressMs, int durationMs);
|
||||
|
|
|
|||
Loading…
Reference in a new issue