41 lines
700 B
Dart
41 lines
700 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class Song {
|
|
final String id;
|
|
final String title;
|
|
final String artist;
|
|
final String? url;
|
|
|
|
Song({
|
|
required this.id,
|
|
required this.title,
|
|
required this.artist,
|
|
this.url,
|
|
});
|
|
}
|
|
|
|
class AudioService extends ChangeNotifier {
|
|
Song? _currentSong;
|
|
bool _isPlaying = false;
|
|
|
|
Song? get currentSong => _currentSong;
|
|
bool get isPlaying => _isPlaying;
|
|
|
|
void playSong(Song song) {
|
|
_currentSong = song;
|
|
_isPlaying = true;
|
|
notifyListeners();
|
|
}
|
|
|
|
void togglePlay() {
|
|
_isPlaying = !_isPlaying;
|
|
notifyListeners();
|
|
}
|
|
|
|
void stopPlay() {
|
|
_currentSong = null;
|
|
_isPlaying = false;
|
|
notifyListeners();
|
|
}
|
|
}
|