import 'package:nut_player/src/model/content_type.dart';
import 'package:nut_player_platform_interface/nut_player_platform_interface.dart';

PlatformContentType createPlatformContent(ContentType type) {
  final contentType = type;
  if (contentType is AutoContentType) {
    return PlatformAutoContentType(urlPath: contentType.urlPath);
  } else if (contentType is HlsContentType) {
    return PlatformHlsContentType(urlPath: contentType.urlPath, isLive: contentType.isLive);
  } else if (contentType is DashContentType) {
    return PlatformDashContentType(urlPath: contentType.urlPath);
  } else if (contentType is Mp4ContentType) {
    return PlatformMp4ContentType(urlPath: contentType.urlPath, isLoop: contentType.isLoop);
  } else {
    throw Error();
  }
}

class PlatformPlayerContentImpl extends PlatformPlayerContent {

  @override PlatformContentType content;
  @override List<PlatformPlayerStatisticRecord> statistics;
  @override List<PlatformPlayerSubtitleRecord> subtitles;

  PlatformPlayerContentImpl({required this.content, required this.statistics, required this.subtitles});
}

class PlatformStatisticRecordImpl extends PlatformPlayerStatisticRecord {

  @override String name;
  @override String urlTemplate;
  @override double start;
  @override double delay;
  @override int count;
  @override PlatformHTTPMethod method;
  @override String? body;

  PlatformStatisticRecordImpl({
    required this.name,
    required this.urlTemplate,
    required this.start,
    required this.delay,
    required this.count,
    required this.method,
    this.body
  });
}

class PlatformSubtitleRecordImpl extends PlatformPlayerSubtitleRecord {

  @override String title;
  @override PlatformSubtitleType type;
  @override String url;
  @override String language;

  PlatformSubtitleRecordImpl({
    required this.title,
    required this.type,
    required this.url,
    required this.language,
  });
}