1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package net.sourceforge.subsonic.androidapp.audiofx; |
20 |
|
|
21 |
|
import android.content.Context; |
22 |
|
import android.media.MediaPlayer; |
23 |
|
import android.media.audiofx.Visualizer; |
24 |
|
import android.util.Log; |
25 |
|
|
26 |
|
|
27 |
|
@link |
28 |
|
|
29 |
|
@author |
30 |
|
@version |
31 |
|
|
|
|
| 64,3% |
Uncovered Elements: 10 (28) |
Complexity: 11 |
Complexity Density: 0,65 |
|
32 |
|
public class VisualizerController { |
33 |
|
|
34 |
|
private static final String TAG = VisualizerController.class.getSimpleName(); |
35 |
|
private static final int PREFERRED_CAPTURE_SIZE = 128; |
36 |
|
|
37 |
|
private final Context context; |
38 |
|
private Visualizer visualizer; |
39 |
|
|
40 |
|
|
|
|
| 66,7% |
Uncovered Elements: 1 (3) |
Complexity: 2 |
Complexity Density: 0,67 |
|
41 |
1
|
static {... |
42 |
1
|
try { |
43 |
1
|
Class.forName("android.media.audiofx.Visualizer"); |
44 |
|
} catch (Exception ex) { |
45 |
0
|
throw new RuntimeException(ex); |
46 |
|
} |
47 |
|
} |
48 |
|
|
49 |
|
|
50 |
|
@link |
51 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
52 |
1
|
public static void checkAvailable() throws Throwable {... |
53 |
|
|
54 |
|
} |
55 |
|
|
|
|
| 81,8% |
Uncovered Elements: 2 (11) |
Complexity: 3 |
Complexity Density: 0,33 |
|
56 |
1
|
public VisualizerController(Context context, MediaPlayer mediaPlayer) {... |
57 |
1
|
this.context = context; |
58 |
1
|
try { |
59 |
1
|
visualizer = new Visualizer(mediaPlayer.getAudioSessionId()); |
60 |
|
} catch (Throwable x) { |
61 |
0
|
Log.w(TAG, "Failed to create visualizer.", x); |
62 |
|
} |
63 |
|
|
64 |
1
|
if (visualizer != null) { |
65 |
1
|
int[] captureSizeRange = Visualizer.getCaptureSizeRange(); |
66 |
1
|
int captureSize = Math.max(PREFERRED_CAPTURE_SIZE, captureSizeRange[0]); |
67 |
1
|
captureSize = Math.min(captureSize, captureSizeRange[1]); |
68 |
1
|
visualizer.setCaptureSize(captureSize); |
69 |
|
} |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
72 |
1
|
public boolean isAvailable() {... |
73 |
1
|
return visualizer != null; |
74 |
|
} |
75 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
0
|
public boolean isEnabled() {... |
77 |
0
|
return isAvailable() && visualizer.getEnabled(); |
78 |
|
} |
79 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
80 |
0
|
public void release() {... |
81 |
0
|
if (isAvailable()) { |
82 |
0
|
visualizer.release(); |
83 |
|
} |
84 |
|
} |
85 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
86 |
28
|
public Visualizer getVisualizer() {... |
87 |
28
|
return visualizer; |
88 |
|
} |
89 |
|
} |
90 |
|
|