Skip to content

Commit f33e5a1

Browse files
committed
Fixed issue with HXSound being disabled by default. Removed Log statements from release build.
1 parent 72fac9c commit f33e5a1

11 files changed

+132
-74
lines changed

apk/HXAudioPlayer_Demo.apk

334 Bytes
Binary file not shown.

app/app.iml

+5
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,19 @@
7676
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
7777
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
7878
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
79+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
7980
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
8081
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
8182
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
8283
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
84+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
8385
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
86+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
8487
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
8588
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
89+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
8690
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
91+
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
8792
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
8893
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
8994
</content>

hxaudio/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ android {
88
minSdkVersion 9
99
targetSdkVersion 25
1010
versionCode 1
11-
versionName "3.1.1"
11+
versionName "3.1.2"
1212
}
1313
buildTypes {
1414
release {

hxaudio/proguard-rules.pro

+9
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,12 @@
1515
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
1616
# public *;
1717
#}
18+
19+
-assumenosideeffects class android.util.Log {
20+
public static boolean isLoggable(java.lang.String, int);
21+
public static int v(...);
22+
public static int i(...);
23+
public static int w(...);
24+
public static int d(...);
25+
public static int e(...);
26+
}

hxaudio/src/main/java/com/huhx0015/hxaudio/audio/HXMusic.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.huhx0015.hxaudio.audio;
22

33
import android.content.Context;
4-
import android.util.Log;
54
import com.huhx0015.hxaudio.builder.HXMusicBuilder;
65
import com.huhx0015.hxaudio.interfaces.HXMusicEngineListener;
76
import com.huhx0015.hxaudio.interfaces.HXMusicListener;
87
import com.huhx0015.hxaudio.model.HXMusicItem;
8+
import com.huhx0015.hxaudio.utils.HXLog;
99

1010
/** -----------------------------------------------------------------------------------------------
1111
* [HXMusic] CLASS
@@ -97,17 +97,17 @@ public synchronized void initMusic(HXMusicItem music, int position, boolean isGa
9797
private boolean checkStatus(HXMusicItem music) {
9898

9999
if (hxMusicStatus.equals(HXMusicStatus.DISABLED)) {
100-
Log.e(LOG_TAG, "ERROR: checkStatus(): Music has been currently disabled.");
100+
HXLog.e(LOG_TAG, "ERROR: checkStatus(): Music has been currently disabled.");
101101
return false;
102102
} else if (music == null) {
103-
Log.e(LOG_TAG, "ERROR: checkStatus(): Music item was null.");
103+
HXLog.e(LOG_TAG, "ERROR: checkStatus(): Music item was null.");
104104
return false;
105105
} else if (music.getMusicResource() == 0 && music.getMusicUrl() == null) {
106-
Log.e(LOG_TAG, "ERROR: checkStatus(): No music resource or url was specified.");
106+
HXLog.e(LOG_TAG, "ERROR: checkStatus(): No music resource or url was specified.");
107107
return false;
108108
} else if (hxMusicItem != null && (hxMusicItem.getMusicResource() == music.getMusicResource())) {
109109
if (hxMusicEngine != null && hxMusicEngine.isPlaying()) {
110-
Log.e(LOG_TAG, "ERROR: checkStatus(): Specified song is already playing!");
110+
HXLog.e(LOG_TAG, "ERROR: checkStatus(): Specified song is already playing!");
111111
return false;
112112
}
113113
}
@@ -192,7 +192,7 @@ public static void pauseMusic() {
192192
public static void resumeMusic(final Context context) {
193193

194194
if (context == null || context.getApplicationContext() == null) {
195-
Log.e(LOG_TAG, "ERROR: resumeMusic(): Context cannot be null.");
195+
HXLog.e(LOG_TAG, "ERROR: resumeMusic(): Context cannot be null.");
196196
} else if (hxMusic != null && hxMusic.hxMusicStatus.equals(HXMusicStatus.PAUSED) &&
197197
hxMusic.hxMusicEngine != null) {
198198
Thread playThread = new Thread(new Runnable() {
@@ -205,7 +205,7 @@ public void run() {
205205
});
206206
playThread.start();
207207
} else {
208-
Log.e(LOG_TAG, "ERROR: resumeMusic(): Music could not be resumed.");
208+
HXLog.e(LOG_TAG, "ERROR: resumeMusic(): Music could not be resumed.");
209209
}
210210
}
211211

@@ -214,7 +214,7 @@ public static void stopMusic() {
214214
if (hxMusic != null && hxMusic.hxMusicEngine != null) {
215215
hxMusic.hxMusicEngine.stopMusic();
216216
} else {
217-
Log.e(LOG_TAG, "ERROR: stopMusic(): Music could not be stopped.");
217+
HXLog.e(LOG_TAG, "ERROR: stopMusic(): Music could not be stopped.");
218218
}
219219
}
220220

hxaudio/src/main/java/com/huhx0015/hxaudio/audio/HXMusicEngine.java

+21-21
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import android.media.MediaPlayer;
88
import android.net.Uri;
99
import android.os.Build;
10-
import android.util.Log;
1110
import com.huhx0015.hxaudio.interfaces.HXMusicEngineListener;
1211
import com.huhx0015.hxaudio.model.HXMusicItem;
12+
import com.huhx0015.hxaudio.utils.HXLog;
1313

1414
/** -----------------------------------------------------------------------------------------------
1515
* [HXMusicEngine] CLASS
@@ -49,7 +49,7 @@ synchronized boolean initMusicEngine(HXMusicItem music, final int position, fina
4949

5050
// Stops any music currently playing in the background.
5151
if (currentPlayer != null && currentPlayer.isPlaying()) {
52-
Log.d(LOG_TAG, "PREPARING: initMusicEngine(): Song currently playing in the background. Stopping playback before switching to a new song.");
52+
HXLog.d(LOG_TAG, "PREPARING: initMusicEngine(): Song currently playing in the background. Stopping playback before switching to a new song.");
5353
currentPlayer.stop();
5454
}
5555

@@ -67,7 +67,7 @@ public void onPrepared(MediaPlayer currentPlayer) {
6767

6868
if (musicPosition != 0) {
6969
currentPlayer.seekTo(musicPosition);
70-
Log.d(LOG_TAG, "PREPARING: onPrepared(): MediaPlayer position set to: " + position);
70+
HXLog.d(LOG_TAG, "PREPARING: onPrepared(): MediaPlayer position set to: " + position);
7171
}
7272

7373
// GAPLESS: If gapless mode is enabled, the secondary MediaPlayer will begin
@@ -82,10 +82,10 @@ public void onPrepared(MediaPlayer currentPlayer) {
8282
nextPlayer.setOnCompletionListener(nextPlayerCompletionListener);
8383
nextPlayer.setOnBufferingUpdateListener(playerBufferingUpdateListener);
8484

85-
Log.d(LOG_TAG, "PREPARING: Gapless mode prepared.");
85+
HXLog.d(LOG_TAG, "PREPARING: Gapless mode prepared.");
8686
} else {
8787
currentPlayer.setLooping(isLooped); // Sets the looping attribute.
88-
Log.d(LOG_TAG, "PREPARING: onPrepared(): MediaPlayer looping status: " + isLooped);
88+
HXLog.d(LOG_TAG, "PREPARING: onPrepared(): MediaPlayer looping status: " + isLooped);
8989
}
9090

9191
currentPlayer.start(); // Begins playing the music.
@@ -95,7 +95,7 @@ public void onPrepared(MediaPlayer currentPlayer) {
9595
musicEngineListener.onMusicEnginePrepared();
9696
}
9797

98-
Log.d(LOG_TAG, "MUSIC: onPrepared(): Music playback has begun.");
98+
HXLog.d(LOG_TAG, "MUSIC: onPrepared(): Music playback has begun.");
9999
}
100100
});
101101

@@ -120,7 +120,7 @@ public void onCompletion(MediaPlayer mp) {
120120
musicEngineListener.onMusicEngineCompletion();
121121
}
122122

123-
Log.d(LOG_TAG, "MUSIC: onCompletion(): Music playback has completed.");
123+
HXLog.d(LOG_TAG, "MUSIC: onCompletion(): Music playback has completed.");
124124
}
125125
}
126126
});
@@ -133,7 +133,7 @@ public void onCompletion(MediaPlayer mp) {
133133

134134
return true;
135135
} else {
136-
Log.e(LOG_TAG, "ERROR: initMusicEngine(): An error occurred while preparing the MediaPlayer object.");
136+
HXLog.e(LOG_TAG, "ERROR: initMusicEngine(): An error occurred while preparing the MediaPlayer object.");
137137
return false;
138138
}
139139
}
@@ -145,16 +145,16 @@ private MediaPlayer prepareMediaPlayer(Context context) {
145145
// Sets up the MediaPlayer object for the music to be played.
146146
MediaPlayer player = new MediaPlayer(); // Initializes the MediaPlayer.
147147
player.setAudioStreamType(AudioManager.STREAM_MUSIC); // Sets the audio type for the MediaPlayer object.
148-
Log.d(LOG_TAG, "PREPARING: prepareMediaPlayer(): MediaPlayer stream type set to STREAM_MUSIC.");
148+
HXLog.d(LOG_TAG, "PREPARING: prepareMediaPlayer(): MediaPlayer stream type set to STREAM_MUSIC.");
149149

150150
// Prepares the specified music URL for playback.
151151
if (musicItem.getMusicUrl() != null) {
152152
try {
153153
player.setDataSource(context, Uri.parse(musicItem.getMusicUrl()));
154154
player.prepareAsync(); // Prepares the MediaPlayer object asynchronously.
155-
Log.d(LOG_TAG, "PREPARING: prepareMediaPlayer(): MediaPlayer URL was set, preparing MediaPlayer...");
155+
HXLog.d(LOG_TAG, "PREPARING: prepareMediaPlayer(): MediaPlayer URL was set, preparing MediaPlayer...");
156156
} catch (Exception e) {
157-
Log.e(LOG_TAG, "ERROR: prepareMediaPlayer(): An error occurred while loading the music from the specified URL: " + e.getLocalizedMessage());
157+
HXLog.e(LOG_TAG, "ERROR: prepareMediaPlayer(): An error occurred while loading the music from the specified URL: " + e.getLocalizedMessage());
158158
}
159159
}
160160

@@ -164,9 +164,9 @@ else if (musicItem.getMusicResource() != 0) {
164164
AssetFileDescriptor asset = context.getResources().openRawResourceFd(musicItem.getMusicResource());
165165
player.setDataSource(asset.getFileDescriptor(), asset.getStartOffset(), asset.getLength());
166166
player.prepareAsync(); // Prepares the MediaPlayer object asynchronously.
167-
Log.d(LOG_TAG, "PREPARING: prepareMediaPlayer(): MediaPlayer resource was set, preparing MediaPlayer...");
167+
HXLog.d(LOG_TAG, "PREPARING: prepareMediaPlayer(): MediaPlayer resource was set, preparing MediaPlayer...");
168168
} catch (Exception e) {
169-
Log.e(LOG_TAG, "ERROR: prepareMediaPlayer(): An error occurred while loading the music resource: " + e.getLocalizedMessage());
169+
HXLog.e(LOG_TAG, "ERROR: prepareMediaPlayer(): An error occurred while loading the music resource: " + e.getLocalizedMessage());
170170
}
171171
}
172172

@@ -195,7 +195,7 @@ public void onCompletion(MediaPlayer mp) {
195195
nextPlayer = prepareMediaPlayer(context); // Prepares the next MediaPlayer.
196196
nextPlayer.setOnPreparedListener(nextPlayerPreparedListener);
197197
mp.release(); // Releases the previous MediaPlayer.
198-
Log.d(LOG_TAG, "MUSIC: onCompletion(): Preparing next MediaPlayer object for gapless playback.");
198+
HXLog.d(LOG_TAG, "MUSIC: onCompletion(): Preparing next MediaPlayer object for gapless playback.");
199199
}
200200
};
201201

@@ -210,7 +210,7 @@ public void onBufferingUpdate(MediaPlayer mp, int percent) {
210210
musicEngineListener.onMusicEngineBufferingUpdate(percent);
211211
}
212212

213-
Log.d(LOG_TAG, "MUSIC: initMusicEngine(): Music buffering at: " + percent);
213+
HXLog.d(LOG_TAG, "MUSIC: initMusicEngine(): Music buffering at: " + percent);
214214
}
215215
};
216216

@@ -239,12 +239,12 @@ int pauseMusic() {
239239
musicEngineListener.onMusicEnginePause();
240240
}
241241

242-
Log.d(LOG_TAG, "MUSIC: pauseMusic(): Music playback has been paused.");
242+
HXLog.d(LOG_TAG, "MUSIC: pauseMusic(): Music playback has been paused.");
243243
return musicPosition;
244244
}
245245
}
246246

247-
Log.e(LOG_TAG, "ERROR: pauseMusic(): Music could not be paused.");
247+
HXLog.e(LOG_TAG, "ERROR: pauseMusic(): Music could not be paused.");
248248
return 0;
249249
}
250250

@@ -256,10 +256,10 @@ boolean release() {
256256
currentPlayer.release();
257257
currentPlayer = null;
258258

259-
Log.d(LOG_TAG, "RELEASE: release(): MediaPlayer object has been released.");
259+
HXLog.d(LOG_TAG, "RELEASE: release(): MediaPlayer object has been released.");
260260
return true;
261261
} else {
262-
Log.e(LOG_TAG, "ERROR: release(): MediaPlayer object is null and cannot be released.");
262+
HXLog.e(LOG_TAG, "ERROR: release(): MediaPlayer object is null and cannot be released.");
263263
return false;
264264
}
265265
}
@@ -275,10 +275,10 @@ boolean stopMusic() {
275275
musicEngineListener.onMusicEngineStop();
276276
}
277277

278-
Log.d(LOG_TAG, "MUSIC: stopMusic(): Music playback has been stopped.");
278+
HXLog.d(LOG_TAG, "MUSIC: stopMusic(): Music playback has been stopped.");
279279
return true;
280280
} else {
281-
Log.e(LOG_TAG, "ERROR: stopMusic(): Cannot stop music, as MediaPlayer object is already null.");
281+
HXLog.e(LOG_TAG, "ERROR: stopMusic(): Cannot stop music, as MediaPlayer object is already null.");
282282
return false;
283283
}
284284
}

0 commit comments

Comments
 (0)