diff --git a/android/app/src/main/java/com/raysummee/raylex/raylex/finder/MusicFinder.java b/android/app/src/main/java/com/raysummee/raylex/raylex/finder/MusicFinder.java index 36b9075..da70f4a 100644 --- a/android/app/src/main/java/com/raysummee/raylex/raylex/finder/MusicFinder.java +++ b/android/app/src/main/java/com/raysummee/raylex/raylex/finder/MusicFinder.java @@ -53,7 +53,7 @@ public void prepare() { int idColumn = cur.getColumnIndex(MediaStore.Audio.Media._ID); int trackIdColumn = cur.getColumnIndex(MediaStore.Audio.Media.TRACK); - String musicDirPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath(); + //String musicDirPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_MUSIC).getAbsolutePath(); do { String trackIdStr = cur.getString(trackIdColumn); int trackId = 0; @@ -70,10 +70,11 @@ public void prepare() { mAudioPath.get(cur.getLong(idColumn)), mAlbumMap.get(cur.getLong(albumArtColumn)), trackId); - if (song.uri.startsWith(musicDirPath)) { + //if (song.uri.startsWith(musicDirPath)) { mSongs.add(song); - } + //} } while (cur.moveToNext()); + cur.close(); } @@ -84,6 +85,7 @@ private void loadAlbumArt() { null, null); + assert cursor != null; if (cursor.moveToFirst()) { do { long id = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Albums._ID)); @@ -101,6 +103,7 @@ private void loadAudioPath() { null, null); + assert cursor != null; if (cursor.moveToFirst()) { do { long id = cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Media._ID)); @@ -195,6 +198,7 @@ public String getURI() { Cursor mediaCursor = getContentResolver().query(mediaContentUri, projection, selection, selectionArgs, null); + assert mediaCursor != null; if(mediaCursor.getCount() >= 0) { mediaCursor.moveToPosition(0); // String title = mediaCursor.getString(mediaCursor.getColumnIndex(MediaStore.Audio.Media.TITLE)); @@ -224,6 +228,7 @@ public String getAlbumArt() { new String[] {String.valueOf(albumId)}, null); + assert cursor != null; if (cursor.moveToFirst()) { path = cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Albums.ALBUM_ART)); // do whatever you need to do diff --git a/android/app/src/main/java/com/raysummee/raylex/raylex/player/PlayerController.java b/android/app/src/main/java/com/raysummee/raylex/raylex/player/PlayerController.java index 2fe603d..ec9e871 100644 --- a/android/app/src/main/java/com/raysummee/raylex/raylex/player/PlayerController.java +++ b/android/app/src/main/java/com/raysummee/raylex/raylex/player/PlayerController.java @@ -136,6 +136,14 @@ public void playPausedMusic(){ } } + public int getSessionIdMusic(){ + if(exoPlayer!=null){ + return exoPlayer.getAudioSessionId(); + }else{ + return 101; + } + } + private final Runnable sendData = new Runnable(){ public void run(){ @@ -175,6 +183,9 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result case "playPausedMusic": playPausedMusic(); break; + case "getSessionMusicId": + result.success(getSessionIdMusic()); + break; default: result.notImplemented(); } diff --git a/lib/logic/playerLogic.dart b/lib/logic/playerLogic.dart index 4b3e554..f733906 100644 --- a/lib/logic/playerLogic.dart +++ b/lib/logic/playerLogic.dart @@ -50,6 +50,10 @@ class PlayerLogic{ await _platform.invokeMethod("playPausedMusic"); } + Future getAudioSessionID() async{ + return await _platform.invokeMethod("getSessionMusicId"); + } + void seekToMusic(double seek) async{ await _platform.invokeMethod("seekTo",{ "seek": seek, diff --git a/lib/ux/components/appBars/libraryAppBar.dart b/lib/ux/components/appBars/libraryAppBar.dart index 329dd14..b140f63 100644 --- a/lib/ux/components/appBars/libraryAppBar.dart +++ b/lib/ux/components/appBars/libraryAppBar.dart @@ -87,83 +87,56 @@ class _LibraryAppBarState extends State with TickerProviderStateM height: 200, child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.end, children: [ Container( - margin: EdgeInsets.fromLTRB(0, 0, 0, 10), + margin: EdgeInsets.only(bottom: 2), child: Text( "Library", style: TextStyle( color: Colors.white, - fontSize: 25, + fontSize: 27, fontWeight: FontWeight.bold ) ), ), - Column( - mainAxisAlignment: MainAxisAlignment.end, + Row( children: [ - Container( - margin: EdgeInsets.fromLTRB(0, 5, 0, 5), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(40), - boxShadow: [ - - ] + IconButton( + icon: Icon( + Icons.fast_rewind, + color: Colors.white, ), - width: 140, - height: 110, - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: Container( - color: Colors.white, - child: Image( - image: AssetImage("lib/assets/images/white-headphone.jpg"), - fit: BoxFit.cover, - ), - ), - ) + onPressed: (){} ), - Row( - children: [ - IconButton( - icon: Icon( - Icons.fast_rewind, - color: Colors.white, - ), - onPressed: (){} - ), - IconButton( - iconSize: 35, - icon: AnimatedIcon( - icon: AnimatedIcons.play_pause, - progress: __animationController, - color: Colors.white, - ), - onPressed: (){ - if(isPlaying){ - setState(() { - isPlaying = false; - }); - _playerLogic.pauseMusic(); - //__animationController.reverse(); - } - else{ - setState(() { - isPlaying = true; - }); - _playerLogic.playPausedMusic(); - //__animationController.forward(); - } - } - ), - IconButton( - icon: Icon( - Icons.fast_forward,color: Colors.white, - ), - onPressed: (){} - ), - ], + IconButton( + iconSize: 35, + icon: AnimatedIcon( + icon: AnimatedIcons.play_pause, + progress: __animationController, + color: Colors.white, + ), + onPressed: (){ + if(isPlaying){ + setState(() { + isPlaying = false; + }); + _playerLogic.pauseMusic(); + //__animationController.reverse(); + } + else{ + setState(() { + isPlaying = true; + }); + _playerLogic.playPausedMusic(); + //__animationController.forward(); + } + } + ), + IconButton( + icon: Icon( + Icons.fast_forward,color: Colors.white, + ), + onPressed: (){} ), ], ) diff --git a/lib/ux/components/lists/verticalListSimple.dart b/lib/ux/components/lists/verticalListSimple.dart index 81aae45..b11cf12 100644 --- a/lib/ux/components/lists/verticalListSimple.dart +++ b/lib/ux/components/lists/verticalListSimple.dart @@ -22,8 +22,10 @@ class _VerticalListSimpleState extends State { child: ListView.builder( itemCount: widget.songinfo.length, scrollDirection: Axis.vertical, + padding: EdgeInsets.fromLTRB(0, 0, 0, 0), itemBuilder: (context, index){ return ListTile( + title: Text( widget.songinfo.elementAt(index).title, style: ((){ diff --git a/lib/ux/pages/libraryPages.dart b/lib/ux/pages/libraryPages.dart index 2fcf035..fd63db5 100644 --- a/lib/ux/pages/libraryPages.dart +++ b/lib/ux/pages/libraryPages.dart @@ -11,9 +11,6 @@ class LibraryPages extends StatefulWidget { } class _LibraryPagesState extends State { - final List list = ["Zubeen Garg", "Sonu Nigam", "Justin Beiber", "ED Sheeran", "Ariana Grand"]; - - final List listAlbums = ["Misson China", "Dil Jaale", "Sorry", "Safaar", "Promises"]; @override Widget build(BuildContext context) { @@ -25,7 +22,7 @@ class _LibraryPagesState extends State { builder: (context, snap){ if(snap.data!=null){ List list = snap.data; - return list.isNotEmpty?VerticalListSimple(list):Center(child: Text("No songs found"),); + return list.isNotEmpty?VerticalListSimple(list):Expanded(child: Center(child: Text("No songs found"),)); }else{ return Expanded( child: Column( diff --git a/lib/ux/pages/navPages.dart b/lib/ux/pages/navPages.dart index d10add2..c798c69 100644 --- a/lib/ux/pages/navPages.dart +++ b/lib/ux/pages/navPages.dart @@ -18,7 +18,7 @@ class _NavPagesState extends State { @override Widget build(BuildContext context) { return Scaffold( - extendBody: true, + extendBody: false, //body of the nav bar body: IndexedStack( index: _currentIndex, diff --git a/pubspec.yaml b/pubspec.yaml index d06a92c..34ae1a3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -26,6 +26,7 @@ dependencies: flutter_icons: ^1.1.0 provider: ^3.0.0 +