Sunday, May 29, 2011

0.18 - Small Update

I am in the process of writing an audio engine that will let me do a lot more things compared to the build in MediaPlayer class.  I'll be able to support more audio file types, and a bunch of essential features like  gapless playback, an equalizer, and crossfading once it is complete.  It is a fairly large task so that is why this release is mostly bug fixes.

Download here

Changelog:

0.18: (05/29/11)
-Added .m4a to the list of supported filetypes
-Added .jpeg to the list of supported image filetypes
-Added new permission "android.permission.BROADCAST_STICKY"
-Improved headset auto play/pause
-Added "Loop Playlist" as a selection for (Playlist->On Playlist Completion) preference
-New Preference (General->Headset Preferences->Prevent Sleep): Lets you set how long
    the device should stay active to wait for a headset to be plugged back in
-New Preference (Library->Song Actions->Queue Album On Song Play Action): When playing
    a single song, add the rest of the album to the playlist

fixes:
-Catch OutOfMemoryError when loading an image too large to prevent a force close
-Non default wake modes will no longer let the device sleep when pressing the
    power button during playback
-Fixed issue where playback would stop when turning the screen back on
-Fixed bug causing track to play back twice at the same time
-Fixed crash involving an illegal state in a ListView

Wednesday, May 25, 2011

Album Art instructions

I never really explained how the album art works, so I will do that now.  First off lets look at the preferences:

Preferences -> General -> Album Art Preferences (near the bottom)
-Auto Download Album Art: Check this if you want gmmp to automatically query google images and try to find the art for the album (Internet connection is needed for this to work)
-Save in Lossless Format: Choose whether to save downloaded images as PNG or JPEG.  Lossless = PNG
-Album Art Download Location: You shouldn't have to touch this unless you want to change where the art downloads to.  By default art will download to [external storage]/gmmp/albumart. If you want to, you can specify the path and override the default

Preferences -> Now Playing
-Show Album Art: Check this to enable the now playing view to show the art in the background

Automatic Album Art Recognition:
Here is the flow that the now playing screen uses when trying to find the art:

1) The database is scanned to see if there is an image already set for the album
2) The file is checked for embedded art
3) The "Album Art Download Location" is scanned to see if the art was already downloaded (from a previous install).  It searches for a specific filename so you cannot just put anything here.
4) If there still isn't anything found.  The folder of the current playing song will be scanned for any images.
5) If the auto download setting is enabled, a query to google images is sent and the first valid image is used

If any of steps 3-5 actually succeeds, that image will be stored into the database as the image for the album.

Valid image formats: jpg, png, bmp, and gif (art embedded into the audio file is not currently supported, but will be in the future)

Manual Album Art Downloading:

From the Genre, Artist, or Album view, find the album you want to search for art.  Press and hold on the album until the context menu comes up.  Select "Album Art".  You will be brought to a screen with a spinner at the top with 4 selections.  Local Search, Google Image Search, Bing Image Search, and Current Image.

Current Image: If there is already art in the database for this album, this will be the default.. showing the currently selected image for the album

Local Search:  Right now this will scan the folder your album is in for any images.

Google Image Search (Needs internet): Will send a query to google images and show the first 8-10 results.  The downloads are not instant so if you see a box with a grey background, just wait a bit for it to download

Bing Image Search (Needs internet): Works the same way as the google image search, just uses a different search engine


How to select the image to use.  If one of the searches returned some results, just scroll through to the image you want and press the select button.  Now when you play anything from that album, the now playing screen should show the image in the background

edit: 07/11/11 updated instructions with embedded art support

Sunday, May 22, 2011

0.17 - Improved scan speed + fixes

I discovered a pretty nasty bug that required me to change how the database gets accessed.  The performance should be the same but doing things while scanning should be a bit more stable now.  I also made some minor changes to the album art stuff to make it more efficient

Changelog:
0.17: (05/22/11)
-Improved file scan speed
-Scan notification updates to show # of tracks found while scanning
-Album art autodownloader will try another image if the first attempt fails
-If album art download cannot find anything or is turned off, the track's folder
    is scanned for images to use for album art
-The local cache is checked for album art before attempting to auto download

fixes:
-Fixed issues with the database being locked causing a crash while scanning
-Fixed issue where an album download timeout/error causes the now playing ui
    to stop updating for awhile


Download 0.17 alpha here

Friday, May 20, 2011

0.16 - Album Art

I just finished up the next version of gmmp and I am very pleased with the results.  The player is looking much more professional now that album art was added.  I sum up the new features in the change log, but the basic premise around this release was strictly album art.

Changelog:

0.16: (05/20/11)
-Updated Now Playing view to show album art and changed the metadata display
-Added option to automatically download album art
-Added manual album art selection that will look for album art using the following:
    - Local Folder
    - Bing Image Search
    - Google Image Search
-Added option to save images as PNG or JPG

Download 0.16 Alpha here

I downloaded a screenshot app for my thunderbolt so I took some screens on that instead of the emulator

Screenshots:





 


All of the screens can be viewed here: http://gonemadmusicplayer.blogspot.com/p/screenshots.html

Dev: How to search google images in java

I'm finishing up the final touches of the next version which will include album art.  One of the features I included was a built in google image search to look for album art.  It was extremely simple to set up so I'd like to share some of the code.  I decided to use JSON as a return type for my queries and there are some simple free classes out there to parse the results here http://json.org/java/

The google image api documentation shows us how to do a simple query, so lets construct one.

String search_string = "nachos";
String query = "https://ajax.googleapis.com/ajax/services/earch/images?v=1.0&q=" + search_string;

Now do a http GET

HttpClient client = new DefaultHttpClient();  
try
{   
   HttpGet request = new HttpGet(query);
          
   HttpResponse http_response = client.execute(request);
   HttpEntity entity = http_response.getEntity();

   if (entity != null)
   {
      InputStream instream = entity.getContent();
      //convertInputStreamToString does exactly what it says.. its trivial so no need to show the code
      String response = convertInputStreamToString(instream);
      //JSONObject is provided at the link above
      JSONObject json = new JSONObject(response);
      parseJson(json);
                              
      instream.close();
   }
}
catch (Exception ex)
{
    client.getConnectionManager().shutdown();
}       


The parseJson function is where you can get the relevant data out of the results.  The list of valid keys are listed in the api documentation I linked above.  Here is the code for parseJson:

JSONObject response_data = JsonObj.getJSONObject("responseData");
JSONArray results = response_data.getJSONArray("results");

for (int i = 0; i < results.length(); i++)
{
    JSONObject result = (JSONObject)results.get(i);
    //now you can grab data from the result using:
    //result.getInt(key);
    //result.getString(key);
    //etc
}

Now you have access to google image search.  The other google apis work pretty much the same way from what I've seen.

Saturday, May 14, 2011

0.15

I posted earlier today with a screen shot of the view changes.

Changelog:

0.15: (05/14/11)
-Added album count and track count to artist view
-Added year, track count, and album duration to album view
-Added track number, track duration, album, and year to song view
-Added preferences to hide/show extra stats mentioned above
-Moved most of data querying to a background thread to not lag the UI

fixes:
-Fixed MusicService crash on null intent
-Fixed crash on track change when the playlist view appears empty
-Fixed issue where album year was not being scanned in
-Catches sql exception caused by a locked database to prevent force close

Download 0.15 alpha here

Artist / Album / Song stats

I'm finishing up improvements to the library views so they show much more information about the artist/album/song.  Here is what it looks like:


If you select an album to view its songs, they will be ordered by track number.  If you are viewing all the songs, the track number is not displayed and the songs are sorted alphabetically.

There will preferences to choose whether you want to see these extra stats or not.

Saturday, May 7, 2011

0.14 - Bug fixes and application crash reporting

Today I discovered this really neat library called acra which allows you to automatically submit error reports to me if GMMP happens to crash.  I added a preference to enable/disable the crash reports but please keep it enabled if you can.  If the program experiences a force close, a notification will pop up that will let you add any comments about what you were doing during the crash.  Once you hit the okay button an entry gets added to my crash report spreadsheet hosted on google docs (assuming you have an internet connection established).  This should really help me create a stable app.

I fixed up most of the bugs I had discovered in 0.13.  Scanning should work now.  Here is the download link and full change log

Download 0.14:

-Added crash reporting (acra 3.1.2)
-Changed music service to switch to a background service if paused when closing
-Auto Resume When Plugged preference added
-Added button to show folder list of external storage to make setting up a scan easier

fixes:
-Scanner should properly scan entire folder
-Fixed crash involving headset wakelock
-Fixed back button handling on os 2.2+
-Fixed crash in file browser if you pressed back button at the root
-Fixed issue where some devices report a different state value when headset is plugged in

Here is a screenshot of the new button that helps selecting scan directories:

Thursday, May 5, 2011

Headset Monitoring / Button Overrides

In 0.13 I added two new features: Headset Plug Monitoring and Button Overrides.

Headset Plug Monitoring
With this option enabled, gmmp will automatically pause playback if you unplug your headset.  Doing this will trigger gmmp to listen for you to plug the headset back in and automatically start playback again.  This is the only case when the playback is automatically controlled.  If playback was already stopped/paused when you unplug, nothing will happen.  I coded it this way because I always hated when other apps would auto launch when I plugged my headset in, even tho I haven't used them in a day or two.

Button Overrides
This second option lets you use the volume buttons to advance the current track playing or go back to a previous track.  The overrides only take effect if you have music playing, otherwise they will change the volume.  Also due to the way the android OS is set up, the buttons cannot be overridden with the screen off, nor can it capture the key presses if gmmp is not in focus.  I also added an option to use the power button for play/pause, but that only seems to work in the emulator.  It does nothing on my archos nor my thunderbolt.  I'm leaving it in for the time being, but will probably remove it if its not useful to anyone

Edit: Power override option removed in 0.26

Wednesday, May 4, 2011

0.13 Released

So here is the change log for 0.13
-MusicService changed to a Foreground Service
-MusicService now uses PARTIAL_WAKE_LOCK at minimum during playback
-FileScanner uses PARTIAL_WAKE_LOCK during scans
-Added preference to set WakeLock mode during playback
-Scanner sends notifications for start and completion
-Refresh options menu option added for artist/album/genre/song that will requery the library
-Added preference use the volume buttons to go to next/prev track (Only works when screen is on)
-Added preference to use the power button to pause/play (Only works when screen is on && not on all devices)
-All views (besides now playing) will return to now playing view when the back button is pressed
-Preference for automatic pause/play on headset plug/unplug

fixes:
-Menu shows up in the artist/album/genre/song views
-Fixed issue where you couldnt delete the database without a scanpath added
-Scanner was ignoring files who's extension was not all lowercase

The important things to note are that playback will not stop when the screen goes off and there is now an option to pause/play your music automatically when you plug/unplug your headphones

Edit: I have noticed a few issues with 0.13 while using it today, one being the scanner stops after 2 artists or so which is fairly major so use 0.12 til i can fix up the build

Download 0.13 here

Note: I experienced one crash on my thunderbolt when I enabled the volume button override and pressed vol up to go to the next track.. but I was unable to reproduce it... so if anyone else gets that please let me know

Monday, May 2, 2011

0.12 - Scrobbler support + ui/navigation persistence

I mentioned in my earlier post that I had implemented support for Simple LastFM scrobbler and Scrobble Droid.  I also spent the last few hours adding persistence while navigating throughout GMMP.  For example if you are browsing the artist library and scroll halfway down to artists that begin with the letter M, then select an artist to view their albums.  Before when the back button was pressed, the artist list would start from the beginning.  Now the artist list will be in the exact same spot you left it (in this case over the artists beginning with the letter M).  The artist library view, album library view, genre library view, and browser view will now behave this way.  GMMP should also start back up in the last view you were looking at.

Download 0.12 alpha here:

Sunday, May 1, 2011

The one month mark

A month ago is when I started my experiment on creating a music player in a weekend.  It is crazy when I look back at some of those screen shots and compare it to the current version.  I have learned a tremendous amount about the android sdk and have really enjoyed working with it so far.  Besides getting native code to build, everything was very simple.

At this point I consider the "core" of gmmp to be fully functional and stable, so I can now concentrate on adding some of the easier to implement features.  I was able to integrate in scrobbler support today in only a few hours.  Scrobble Droid and Simple Last.FM Scrobbler are supported and will be able to be enabled in the general preferences area.  There are a few minor unrelated things I would like to address and then I will package up a new build and put up a link.