aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-04-25 21:35:09 -0700
committerScott Jackson <daneren2005@gmail.com>2013-04-25 21:35:09 -0700
commita4208e2bbf70836bf2c233f86053347371af29b5 (patch)
tree6903c1382270318492a156eab7f930af98353298 /subsonic-android/src
parentdc4ee19b5a2e0ed0de170f7372075a13e9bdd88d (diff)
downloaddsub-a4208e2bbf70836bf2c233f86053347371af29b5.tar.gz
dsub-a4208e2bbf70836bf2c233f86053347371af29b5.tar.bz2
dsub-a4208e2bbf70836bf2c233f86053347371af29b5.zip
Add in a check to try to kill the LPA player on S3
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java16
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java19
2 files changed, 35 insertions, 0 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
index b78e25d7..ed869daf 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceImpl.java
@@ -63,6 +63,7 @@ import android.os.Looper;
import android.os.PowerManager;
import android.util.Log;
import github.daneren2005.dsub.activity.SubsonicTabActivity;
+import github.daneren2005.dsub.util.FileUtil;
import java.net.URLEncoder;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@@ -88,6 +89,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
private final IBinder binder = new SimpleServiceBinder<DownloadService>(this);
private Looper mediaPlayerLooper;
+ private MediaPlayer lpaPlayer;
private MediaPlayer mediaPlayer;
private MediaPlayer nextMediaPlayer;
private boolean nextSetup = false;
@@ -145,6 +147,19 @@ public class DownloadServiceImpl extends Service implements DownloadService {
public void run() {
Looper.prepare();
+ // LPA Player on some devices causes weird issues, hold a default media player to mask them
+ try {
+ File randomSong = FileUtil.getAnySong(DownloadServiceImpl.this);
+
+ lpaPlayer = new MediaPlayer();
+ lpaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
+ lpaPlayer.setDataSource(randomSong.getPath());
+ lpaPlayer.prepareAsync();
+ } catch(Exception e) {
+ // Failed to setup, ignore
+ Log.w(TAG, "Failed to setup redirect media player", e);
+ }
+
mediaPlayer = new MediaPlayer();
mediaPlayer.setWakeMode(DownloadServiceImpl.this, PowerManager.PARTIAL_WAKE_LOCK);
@@ -220,6 +235,7 @@ public class DownloadServiceImpl extends Service implements DownloadService {
i.putExtra(AudioEffect.EXTRA_PACKAGE_NAME, getPackageName());
sendBroadcast(i);
+ lpaPlayer.release();
mediaPlayer.release();
if(nextMediaPlayer != null) {
nextMediaPlayer.release();
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java
index bb89a4d3..65f5a37f 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java
@@ -50,6 +50,25 @@ public class FileUtil {
private static final List<String> VIDEO_FILE_EXTENSIONS = Arrays.asList("flv", "mp4", "m4v", "wmv", "avi", "mov", "mpg", "mkv");
private static final List<String> PLAYLIST_FILE_EXTENSIONS = Arrays.asList("m3u");
private static final File DEFAULT_MUSIC_DIR = createDirectory("music");
+
+ public static File getAnySong(Context context) {
+ File dir = getMusicDirectory(context);
+ return getAnySong(context, dir);
+ }
+ private static File getAnySong(Context context, File dir) {
+ for(File file: dir.listFiles()) {
+ if(file.isDirectory()) {
+ return getAnySong(context, file);
+ }
+
+ String extension = getExtension(file.getName());
+ if(MUSIC_FILE_EXTENSIONS.contains(extension)) {
+ return file;
+ }
+ }
+
+ return null;
+ }
public static File getSongFile(Context context, MusicDirectory.Entry song) {
File dir = getAlbumDirectory(context, song);