aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/pheelicks/app/MainActivity.java
diff options
context:
space:
mode:
authorfelixpalmer <felixpalmer@gmail.com>2014-01-07 01:14:57 -0800
committerfelixpalmer <felixpalmer@gmail.com>2014-01-07 01:14:57 -0800
commit57e96262c3d8d33a0b2ec26189ea1f06e690f1c3 (patch)
treedf4caea3f75608320a2ef34d7f218d9547be016e /src/com/pheelicks/app/MainActivity.java
parent4054f8b6e2153b07c5af275372b9609d1019727a (diff)
parenta0227b318b91451daf3fd8d23fb1a5c44a4e187d (diff)
downloadandroid_external_android-visualizer-57e96262c3d8d33a0b2ec26189ea1f06e690f1c3.tar.gz
android_external_android-visualizer-57e96262c3d8d33a0b2ec26189ea1f06e690f1c3.tar.bz2
android_external_android-visualizer-57e96262c3d8d33a0b2ec26189ea1f06e690f1c3.zip
Merge pull request #6 from h6ah4i/feature/tunnel_player_workaroundmaster
Implement Tunnel Player workaround code
Diffstat (limited to 'src/com/pheelicks/app/MainActivity.java')
-rw-r--r--src/com/pheelicks/app/MainActivity.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/com/pheelicks/app/MainActivity.java b/src/com/pheelicks/app/MainActivity.java
index 1b38f44..a2d52dd 100644
--- a/src/com/pheelicks/app/MainActivity.java
+++ b/src/com/pheelicks/app/MainActivity.java
@@ -17,6 +17,7 @@ import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
+import com.pheelicks.utils.TunnelPlayerWorkaround;
import com.pheelicks.visualizer.R;
import com.pheelicks.visualizer.VisualizerView;
import com.pheelicks.visualizer.renderer.BarGraphRenderer;
@@ -29,6 +30,7 @@ import com.pheelicks.visualizer.renderer.LineRenderer;
*/
public class MainActivity extends Activity {
private MediaPlayer mPlayer;
+ private MediaPlayer mSilentPlayer; /* to avoid tunnel player issue */
private VisualizerView mVisualizerView;
/** Called when the activity is first created. */
@@ -42,6 +44,7 @@ public class MainActivity extends Activity {
protected void onResume()
{
super.onResume();
+ initTunnelPlayerWorkaround();
init();
}
@@ -82,6 +85,30 @@ public class MainActivity extends Activity {
mPlayer.release();
mPlayer = null;
}
+
+ if (mSilentPlayer != null)
+ {
+ mSilentPlayer.release();
+ mSilentPlayer = null;
+ }
+ }
+
+ // Workaround (for Galaxy S4)
+ //
+ // "Visualization does not work on the new Galaxy devices"
+ // https://github.com/felixpalmer/android-visualizer/issues/5
+ //
+ // NOTE:
+ // This code is not required for visualizing default "test.mp3" file,
+ // because tunnel player is used when duration is longer than 1 minute.
+ // (default "test.mp3" file: 8 seconds)
+ //
+ private void initTunnelPlayerWorkaround() {
+ // Read "tunnel.decode" system property to determine
+ // the workaround is needed
+ if (TunnelPlayerWorkaround.isTunnelDecodeEnabled(this)) {
+ mSilentPlayer = TunnelPlayerWorkaround.createSilentMediaPlayer(this);
+ }
}
// Methods for adding renderers to visualizer