import 'dart:io';

import 'package:didvan/services/media/media.dart';
import 'package:didvan/views/home/widgets/audio_slider.dart';
import 'package:didvan/views/home/widgets/player_controller_button.dart';
import 'package:flutter/material.dart';

class AudioWidget extends StatelessWidget {
  final String? audioUrl;
  final File? audioFile;
  const AudioWidget({Key? key, this.audioUrl, this.audioFile})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return StreamBuilder<bool>(
      stream: MediaService.audioPlayer.playingStream,
      builder: (context, snapshot) {
        return Row(
          children: [
            Expanded(
              child: AudioSlider(
                tag: audioUrl ?? audioFile!.path,
              ),
            ),
            AudioControllerButton(
              audioFile: audioFile,
              audioUrl: audioUrl,
            ),
          ],
        );
      },
    );
  }
}
