import 'package:aves/remote/remote_http.dart';
import 'package:aves/model/entry/entry.dart';     // AvesEntry concreto (path/remotePath)
import 'package:aves_model/aves_model.dart';      // ✅ espone AvesEntryBase
import 'package:aves_video/aves_video.dart';

class RemoteVideoControllerFactory implements AvesVideoControllerFactory {
  @override
  void init() {
    // opzionale (warm-up o logging)
  }

  @override
  AvesVideoController buildController(
    AvesEntryBase entry, {
    required PlaybackStateHandler playbackStateHandler,
    required VideoSettings settings,
  }) {
    // Nel tuo app layer l’entry è AvesEntry concreto (per path/remotePath)
    final e = entry as AvesEntry;
    final url = RemoteHttp.absUrl(e.remotePath ?? e.path);

    return RemoteNetworkVideoController(
      entry,
      url: url,
      // se la cache non è popolata, il controller farà RemoteHttp.headers()
      httpHeaders: RemoteHttp.peekHeaders(),
      playbackStateHandler: playbackStateHandler,
      settings: settings,
    );
  }
}
