-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from mvolpato/feature/add-playlist
Feature/add playlist
- Loading branch information
Showing
7 changed files
with
162 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.0.2] - add playlist | ||
### Added | ||
- this changelog | ||
- a playlist to the player | ||
|
||
## [0.0.1] - add basic buttons | ||
### Added | ||
- a row of buttons to play, skip, shuffle, and loop. | ||
|
||
[0.0.2]: https://github.com/mvolpato/the-player/releases/tag/0.0.2 | ||
[0.0.1]: https://github.com/mvolpato/the-player/releases/tag/0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
# music_player | ||
# Music Player: create a simple Flutter music player app | ||
|
||
A new Flutter project. | ||
This is a [Flutter](https://flutter.dev) project used during a [series](https://ishouldgotosleep.com/tutorials/music-app/simple-flutter-music-player-app/) of articles | ||
on [I should go to sleep](https://ishouldgotosleep.com). | ||
|
||
## Getting Started | ||
|
||
This project is a starting point for a Flutter application. | ||
## Articles | ||
|
||
A few resources to get you started if this is your first Flutter project: | ||
### Part 1: create the project and add basic buttons | ||
|
||
- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) | ||
- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) | ||
In the [first part](https://ishouldgotosleep.com/tutorials/music-app/simple-flutter-music-player-app/) we | ||
create the Flutter project and play some music from the Internet by using | ||
the package [just_audio](https://pub.dev/packages/just_audio). | ||
|
||
For help getting started with Flutter, view our | ||
[online documentation](https://flutter.dev/docs), which offers tutorials, | ||
samples, guidance on mobile development, and a full API reference. | ||
<img alt="The UI at the end of the first part" src="https://ishouldgotosleep.com/assets/images/blog/music-app/more-buttons.png" width="200" height="433"> | ||
|
||
### Part 2: Improve repository and add a playlist | ||
|
||
TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* File: audio_metadata.dart | ||
* Project: Flutter music player | ||
* Created Date: Thursday February 18th 2021 | ||
* Author: Michele Volpato | ||
* ----- | ||
* Copyright (c) 2021 Michele Volpato | ||
*/ | ||
|
||
/// Represents information about an audio source. | ||
class AudioMetadata { | ||
/// The name of the song/show/recording. | ||
final String title; | ||
|
||
/// URL to an image representing this audio source. | ||
final String artwork; | ||
|
||
AudioMetadata({this.title, this.artwork}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* File: playlist.dart | ||
* Project: Flutter music player | ||
* Created Date: Thursday February 18th 2021 | ||
* Author: Michele Volpato | ||
* ----- | ||
* Copyright (c) 2021 Michele Volpato | ||
*/ | ||
|
||
import 'package:flutter/material.dart'; | ||
import 'package:just_audio/just_audio.dart'; | ||
|
||
/// A list of tiles showing all the audio sources added to the audio player. | ||
/// | ||
/// Audio sources are displayed with a `ListTile` with a leading image (the | ||
/// artwork), and the title of the audio source. | ||
class Playlist extends StatelessWidget { | ||
const Playlist(this._audioPlayer, {Key key}) : super(key: key); | ||
|
||
final AudioPlayer _audioPlayer; | ||
|
||
Widget build(BuildContext context) { | ||
return StreamBuilder<SequenceState>( | ||
stream: _audioPlayer.sequenceStateStream, | ||
builder: (context, snapshot) { | ||
final state = snapshot.data; | ||
final sequence = state?.sequence ?? []; | ||
return ListView( | ||
children: [ | ||
for (var i = 0; i < sequence.length; i++) | ||
ListTile( | ||
selected: i == state.currentIndex, | ||
leading: Image.network(sequence[i].tag.artwork), | ||
title: Text(sequence[i].tag.title), | ||
onTap: () { | ||
_audioPlayer.seek(Duration.zero, index: i); | ||
}, | ||
), | ||
], | ||
); | ||
}, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters