Skip to content

Commit a4759f8

Browse files
committed
all local songs load perfectly now
1 parent 7219278 commit a4759f8

8 files changed

Lines changed: 65 additions & 72 deletions

File tree

android/app/src/main/java/com/raysummee/raylex/raylex/finder/MusicFinder.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void prepare() {
5353
int idColumn = cur.getColumnIndex(MediaStore.Audio.Media._ID);
5454
int trackIdColumn = cur.getColumnIndex(MediaStore.Audio.Media.TRACK);
5555

56-
String musicDirPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
56+
//String musicDirPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath();
5757
do {
5858
String trackIdStr = cur.getString(trackIdColumn);
5959
int trackId = 0;
@@ -70,10 +70,11 @@ public void prepare() {
7070
mAudioPath.get(cur.getLong(idColumn)),
7171
mAlbumMap.get(cur.getLong(albumArtColumn)),
7272
trackId);
73-
if (song.uri.startsWith(musicDirPath)) {
73+
//if (song.uri.startsWith(musicDirPath)) {
7474
mSongs.add(song);
75-
}
75+
//}
7676
} while (cur.moveToNext());
77+
cur.close();
7778

7879
}
7980

@@ -84,6 +85,7 @@ private void loadAlbumArt() {
8485
null,
8586
null);
8687

88+
assert cursor != null;
8789
if (cursor.moveToFirst()) {
8890
do {
8991
long id = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Albums._ID));
@@ -101,6 +103,7 @@ private void loadAudioPath() {
101103
null,
102104
null);
103105

106+
assert cursor != null;
104107
if (cursor.moveToFirst()) {
105108
do {
106109
long id = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media._ID));
@@ -195,6 +198,7 @@ public String getURI() {
195198

196199
Cursor mediaCursor = getContentResolver().query(mediaContentUri, projection, selection, selectionArgs, null);
197200

201+
assert mediaCursor != null;
198202
if(mediaCursor.getCount() >= 0) {
199203
mediaCursor.moveToPosition(0);
200204
// String title = mediaCursor.getString(mediaCursor.getColumnIndex(MediaStore.Audio.Media.TITLE));
@@ -224,6 +228,7 @@ public String getAlbumArt() {
224228
new String[] {String.valueOf(albumId)},
225229
null);
226230

231+
assert cursor != null;
227232
if (cursor.moveToFirst()) {
228233
path = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Albums.ALBUM_ART));
229234
// do whatever you need to do

android/app/src/main/java/com/raysummee/raylex/raylex/player/PlayerController.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ public void playPausedMusic(){
136136
}
137137
}
138138

139+
public int getSessionIdMusic(){
140+
if(exoPlayer!=null){
141+
return exoPlayer.getAudioSessionId();
142+
}else{
143+
return 101;
144+
}
145+
}
146+
139147

140148
private final Runnable sendData = new Runnable(){
141149
public void run(){
@@ -175,6 +183,9 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result
175183
case "playPausedMusic":
176184
playPausedMusic();
177185
break;
186+
case "getSessionMusicId":
187+
result.success(getSessionIdMusic());
188+
break;
178189
default:
179190
result.notImplemented();
180191
}

lib/logic/playerLogic.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class PlayerLogic{
5050
await _platform.invokeMethod("playPausedMusic");
5151
}
5252

53+
Future<int> getAudioSessionID() async{
54+
return await _platform.invokeMethod("getSessionMusicId");
55+
}
56+
5357
void seekToMusic(double seek) async{
5458
await _platform.invokeMethod("seekTo",<String, Object>{
5559
"seek": seek,

lib/ux/components/appBars/libraryAppBar.dart

Lines changed: 37 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -87,83 +87,56 @@ class _LibraryAppBarState extends State<LibraryAppBar> with TickerProviderStateM
8787
height: 200,
8888
child: Row(
8989
mainAxisAlignment: MainAxisAlignment.spaceBetween,
90-
crossAxisAlignment: CrossAxisAlignment.end,
9190
children: <Widget>[
9291
Container(
93-
margin: EdgeInsets.fromLTRB(0, 0, 0, 10),
92+
margin: EdgeInsets.only(bottom: 2),
9493
child: Text(
9594
"Library",
9695
style: TextStyle(
9796
color: Colors.white,
98-
fontSize: 25,
97+
fontSize: 27,
9998
fontWeight: FontWeight.bold
10099
)
101100
),
102101
),
103-
Column(
104-
mainAxisAlignment: MainAxisAlignment.end,
102+
Row(
105103
children: <Widget>[
106-
Container(
107-
margin: EdgeInsets.fromLTRB(0, 5, 0, 5),
108-
decoration: BoxDecoration(
109-
borderRadius: BorderRadius.circular(40),
110-
boxShadow: [
111-
112-
]
104+
IconButton(
105+
icon: Icon(
106+
Icons.fast_rewind,
107+
color: Colors.white,
113108
),
114-
width: 140,
115-
height: 110,
116-
child: ClipRRect(
117-
borderRadius: BorderRadius.circular(10),
118-
child: Container(
119-
color: Colors.white,
120-
child: Image(
121-
image: AssetImage("lib/assets/images/white-headphone.jpg"),
122-
fit: BoxFit.cover,
123-
),
124-
),
125-
)
109+
onPressed: (){}
126110
),
127-
Row(
128-
children: <Widget>[
129-
IconButton(
130-
icon: Icon(
131-
Icons.fast_rewind,
132-
color: Colors.white,
133-
),
134-
onPressed: (){}
135-
),
136-
IconButton(
137-
iconSize: 35,
138-
icon: AnimatedIcon(
139-
icon: AnimatedIcons.play_pause,
140-
progress: __animationController,
141-
color: Colors.white,
142-
),
143-
onPressed: (){
144-
if(isPlaying){
145-
setState(() {
146-
isPlaying = false;
147-
});
148-
_playerLogic.pauseMusic();
149-
//__animationController.reverse();
150-
}
151-
else{
152-
setState(() {
153-
isPlaying = true;
154-
});
155-
_playerLogic.playPausedMusic();
156-
//__animationController.forward();
157-
}
158-
}
159-
),
160-
IconButton(
161-
icon: Icon(
162-
Icons.fast_forward,color: Colors.white,
163-
),
164-
onPressed: (){}
165-
),
166-
],
111+
IconButton(
112+
iconSize: 35,
113+
icon: AnimatedIcon(
114+
icon: AnimatedIcons.play_pause,
115+
progress: __animationController,
116+
color: Colors.white,
117+
),
118+
onPressed: (){
119+
if(isPlaying){
120+
setState(() {
121+
isPlaying = false;
122+
});
123+
_playerLogic.pauseMusic();
124+
//__animationController.reverse();
125+
}
126+
else{
127+
setState(() {
128+
isPlaying = true;
129+
});
130+
_playerLogic.playPausedMusic();
131+
//__animationController.forward();
132+
}
133+
}
134+
),
135+
IconButton(
136+
icon: Icon(
137+
Icons.fast_forward,color: Colors.white,
138+
),
139+
onPressed: (){}
167140
),
168141
],
169142
)

lib/ux/components/lists/verticalListSimple.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ class _VerticalListSimpleState extends State<VerticalListSimple> {
2222
child: ListView.builder(
2323
itemCount: widget.songinfo.length,
2424
scrollDirection: Axis.vertical,
25+
padding: EdgeInsets.fromLTRB(0, 0, 0, 0),
2526
itemBuilder: (context, index){
2627
return ListTile(
28+
2729
title: Text(
2830
widget.songinfo.elementAt(index).title,
2931
style: ((){

lib/ux/pages/libraryPages.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ class LibraryPages extends StatefulWidget {
1111
}
1212

1313
class _LibraryPagesState extends State<LibraryPages> {
14-
final List<String> list = ["Zubeen Garg", "Sonu Nigam", "Justin Beiber", "ED Sheeran", "Ariana Grand"];
15-
16-
final List<String> listAlbums = ["Misson China", "Dil Jaale", "Sorry", "Safaar", "Promises"];
1714

1815
@override
1916
Widget build(BuildContext context) {
@@ -25,7 +22,7 @@ class _LibraryPagesState extends State<LibraryPages> {
2522
builder: (context, snap){
2623
if(snap.data!=null){
2724
List<SongInfo> list = snap.data;
28-
return list.isNotEmpty?VerticalListSimple(list):Center(child: Text("No songs found"),);
25+
return list.isNotEmpty?VerticalListSimple(list):Expanded(child: Center(child: Text("No songs found"),));
2926
}else{
3027
return Expanded(
3128
child: Column(

lib/ux/pages/navPages.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class _NavPagesState extends State<NavPages> {
1818
@override
1919
Widget build(BuildContext context) {
2020
return Scaffold(
21-
extendBody: true,
21+
extendBody: false,
2222
//body of the nav bar
2323
body: IndexedStack(
2424
index: _currentIndex,

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ dependencies:
2626
flutter_icons: ^1.1.0
2727
provider: ^3.0.0
2828

29+
2930

3031

3132

0 commit comments

Comments
 (0)