Skip to content

Commit

Permalink
Update 2.1.0 - Added #3 , Fixed #4 and Fixed #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Pinheiro committed Sep 15, 2021
1 parent 31718b1 commit f6dbf21
Show file tree
Hide file tree
Showing 23 changed files with 408 additions and 151 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.class
*.log
*.pyc
*.lock
*.swp
.DS_Store
.atom/
Expand All @@ -25,6 +26,7 @@
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.metadata
.packages
.pub-cache/
.pub/
Expand Down
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## [2.1.0] - [09.15.2021]
### Features
- **[Added]** `getMap` to `[SongEntity]` as `extension`, this will help to convert `[SongEntity]` to `[SongModel]`. - [#3](https://github.com/LucasPJS/on_audio_room/issues/3)

### Fixes
- **[Fixed]** Entity checker error when using `[addAllTo]`. - [#5](https://github.com/LucasPJS/on_audio_room/issues/5)
- **[Fixed]** No value returning when using `[queryLastPlayed]`. - [#4](https://github.com/LucasPJS/on_audio_room/issues/4)

### Documentation
- Updated `README` documentation.
- Updated `OnAudioRoomExample` documentation to support new `[Flutter 2.5]`.

## [2.0.0] - [07.29.2021]
### Release

Expand Down Expand Up @@ -260,7 +272,8 @@
-->

<!--
- [Added #Issue](Link)
- [Fixed #Issue](Link)
- [Changed #Issue](Link)
https://github.com/LucasPJS/on_audio_room/issues/
- **[Added]** (Text)- [#Issue](Link)
- **[Fixed]** (Text)- [#Issue](Link)
- **[Changed]** (Text)- [#Issue](Link)
-->
95 changes: 48 additions & 47 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import 'package:on_audio_room/on_audio_room.dart';
void main() async {
//Init Room.
await OnAudioRoom().initRoom(RoomType.FAVORITES);
runApp(MaterialApp(home: MyApp()));
runApp(
const MaterialApp(
home: MyApp(),
),
);
}

class MyApp extends StatefulWidget {
Expand All @@ -31,44 +35,60 @@ class MyApp extends StatefulWidget {

class _MyAppState extends State<MyApp> {
//Call audio room.
OnAudioRoom audioRoom = OnAudioRoom();
final OnAudioRoom _audioRoom = OnAudioRoom();
final OnAudioQuery _audioQuery = OnAudioQuery();

@override
void initState() {
super.initState();
_requestPermission();
}

void _requestPermission() async {
bool permissionStatus = await _audioQuery.permissionsStatus();
if (!permissionStatus) {
await _audioQuery.permissionsRequest();
}
setState(() {});
}

@override
void dispose() {
//Remember to close room to avoid memory leaks.
//Choose the better location(page) to add this method.
audioRoom.closeRoom();
_audioRoom.closeRoom();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("OnAudioRoomExample"),
title: const Text("OnAudioRoomExample"),
actions: [
IconButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => Information()),
);
},
icon: Icon(Icons.favorite_outline_rounded))
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(builder: (_) => const Information()),
);
},
icon: const Icon(Icons.favorite_outline_rounded),
)
],
),
body: FutureBuilder<List<SongModel>>(
//In this example we will use [on_audio_query] to query songs from device.
future: OnAudioQuery().queryAudios(null, null, null, true),
builder: (context, item) {
future: OnAudioQuery().querySongs(),
builder: (_, item) {
if (item.data != null) {
List<SongModel> songs = item.data!;
//Display only 10 because it's only a example.
return ListView.builder(
itemCount: 10,
itemBuilder: (context, index) {
itemCount: songs.length,
itemBuilder: (_, index) {
return ListTile(
title: Text(songs[index].title),
subtitle: Text(songs[index].artist),
subtitle: Text(songs[index].artist ?? "No artist"),
//First method from [on_audio_room], here we'll add the selected song
//inside the favorites room.
onTap: () async {
Expand Down Expand Up @@ -98,21 +118,22 @@ class _MyAppState extends State<MyApp> {
// From your [SongModel] just call [toMap] and then [to*Type*Entity()].

//This example we use the [on_audio_query] plugin:
var result = audioRoom.addTo(
_audioRoom.addTo(
RoomType.FAVORITES, //Specify the room type
songs[index].getMap.toFavoritesEntity(),
);
print(result);
},
//Other method, this will clear all the room.
onLongPress: () async {
audioRoom.clearRoom(RoomType.FAVORITES);
_audioRoom.clearRoom(RoomType.FAVORITES);
},
);
},
);
}
return Center(child: CircularProgressIndicator());
return const Center(
child: CircularProgressIndicator(),
);
},
),
);
Expand All @@ -134,7 +155,7 @@ class _InformationState extends State<Information> {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("OnAudioRoomExample"),
title: const Text("OnAudioRoomExample"),
),
body: Center(
//Add to the future builder the specific type.
Expand All @@ -148,9 +169,9 @@ class _InformationState extends State<Information> {
sortType: null, //Null will use the [key] has sort.
),
builder: (context, item) {
if (item.data == null) return CircularProgressIndicator();
if (item.data == null) return const CircularProgressIndicator();

if (item.data!.isEmpty) return Text("No data found");
if (item.data!.isEmpty) return const Text("No data found");

List<FavoritesEntity> favorites = item.data!;
return ListView.builder(
Expand All @@ -161,12 +182,12 @@ class _InformationState extends State<Information> {
subtitle: Text(favorites[index].dateAdded.toString()),
onTap: () async {
//Most the method will return a bool to indicate if method works.
var result = await audioRoom.deleteFrom(
RoomType.FAVORITES, favorites[index].key);
await audioRoom.deleteFrom(
RoomType.FAVORITES,
favorites[index].key,
);
//Call setState to see the result,
setState(() {
print(result);
});
setState(() {});
},
);
},
Expand All @@ -177,23 +198,3 @@ class _InformationState extends State<Information> {
);
}
}

//This method is temporary, soon will be added to [on_audio_query].
//TODO: Add this extension to [on_audio_query] and [toString()].
extension OnAudioFormatter on SongModel {
Map get getMap {
Map tempMap = {};
tempMap["_data"] = this.data;
tempMap["_display_name"] = this.displayName;
tempMap["_id"] = this.id;
tempMap["album"] = this.album;
tempMap["album_id"] = this.albumId;
tempMap["artist"] = this.artist;
tempMap["artist_id"] = this.artistId;
tempMap["date_added"] = this.dateAdded;
tempMap["duration"] = this.duration;
tempMap["title"] = this.title;
tempMap["artwork"] = this.artwork;
return tempMap;
}
}
61 changes: 47 additions & 14 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.1"
version: "2.8.1"
boolean_selector:
dependency: transitive
description:
Expand All @@ -28,7 +28,7 @@ packages:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -88,6 +88,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
hive:
dependency: transitive
description:
Expand All @@ -102,6 +107,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
id3:
dependency: transitive
description:
name: id3
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.3"
matcher:
dependency: transitive
description:
Expand All @@ -115,7 +134,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.7.0"
nanoid:
dependency: transitive
description:
Expand All @@ -129,14 +148,28 @@ packages:
name: on_audio_query
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3+1"
version: "2.2.0"
on_audio_query_platform_interface:
dependency: transitive
description:
name: on_audio_query_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
on_audio_query_web:
dependency: transitive
description:
name: on_audio_query_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
on_audio_room:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "2.0.0"
version: "2.1.0"
on_toast_widget:
dependency: "direct main"
description:
Expand All @@ -157,21 +190,21 @@ packages:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.3"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.2"
path_provider_platform_interface:
dependency: transitive
description:
Expand All @@ -185,14 +218,14 @@ packages:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.3"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.0.2"
plugin_platform_interface:
dependency: transitive
description:
Expand All @@ -206,7 +239,7 @@ packages:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
version: "4.2.3"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -253,7 +286,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
version: "0.4.2"
typed_data:
dependency: transitive
description:
Expand All @@ -274,7 +307,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.5"
version: "2.2.9"
xdg_directories:
dependency: transitive
description:
Expand All @@ -284,4 +317,4 @@ packages:
version: "0.2.0"
sdks:
dart: ">=2.13.0 <3.0.0"
flutter: ">=1.20.0"
flutter: ">=2.0.0"
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
on_audio_query: ^1.1.3+1
on_audio_query: ^2.2.0
on_toast_widget: ^1.0.0
flutter:
sdk: flutter
Expand Down
Loading

0 comments on commit f6dbf21

Please sign in to comment.