import 'dart:async'; import '../models.dart'; import 'player_streams.dart'; mixin PlayerStreamControllersMixin { final playingController = StreamController.broadcast(); final completedController = StreamController.broadcast(); final bufferingController = StreamController.broadcast(); final positionController = StreamController.broadcast(); final durationController = StreamController.broadcast(); final seekableController = StreamController.broadcast(); final bufferController = StreamController.broadcast(); final volumeController = StreamController.broadcast(); final rateController = StreamController.broadcast(); final tracksController = StreamController.broadcast(); final trackController = StreamController.broadcast(); final logController = StreamController.broadcast(); final errorController = StreamController.broadcast(); final audioDeviceController = StreamController.broadcast(); final audioDevicesController = StreamController>.broadcast(); final bufferRangesController = StreamController>.broadcast(); final playbackRestartController = StreamController.broadcast(); final backendSwitchedController = StreamController.broadcast(); PlayerStreams createStreams() { return PlayerStreams( playing: playingController.stream, completed: completedController.stream, buffering: bufferingController.stream, position: positionController.stream, duration: durationController.stream, seekable: seekableController.stream, buffer: bufferController.stream, volume: volumeController.stream, rate: rateController.stream, tracks: tracksController.stream, track: trackController.stream, log: logController.stream, error: errorController.stream, audioDevice: audioDeviceController.stream, audioDevices: audioDevicesController.stream, bufferRanges: bufferRangesController.stream, playbackRestart: playbackRestartController.stream, backendSwitched: backendSwitchedController.stream, ); } Future closeStreamControllers() async { await playingController.close(); await completedController.close(); await bufferingController.close(); await positionController.close(); await durationController.close(); await seekableController.close(); await bufferController.close(); await volumeController.close(); await rateController.close(); await tracksController.close(); await trackController.close(); await logController.close(); await errorController.close(); await audioDeviceController.close(); await audioDevicesController.close(); await bufferRangesController.close(); await playbackRestartController.close(); await backendSwitchedController.close(); } }