Starcommander / StreamRadio

Play network-radio channels, and add your custom channels.
GNU General Public License v3.0
19 stars 8 forks source link

music visualizer #7

Open no-go opened 5 years ago

no-go commented 5 years ago

Hi.

I did it again and build a new "sweded" version. I import some files from https://github.com/GautamChibde/android-audio-visualizer and got after small modifications a music visualisation. The "android-audio-visualizer" project is not GNU license, but Apache 2. Just adopting some file sould not run in any trouble (?)

I am sorry, but my master thesis is on my agenda again and I will leave you alone with your WebRadio App. I hope, I could support you a little bit with some tweaks ;-)

Viele Grüße vom Niederrhein Jochen photo

Starcommander commented 5 years ago

It has nothing to do with "Just adopting some file" , because each line of code is licensed in apache2. Basically it should be possible to include this library without any troubles. http://www.apache.org/licenses/GPL-compatibility.html

Maybe you can supply the differences for this nice changes?! Next time I will try to create a new Version for FDroid. Thanks for your very helpful work.

no-go commented 5 years ago

Thanks for your very helpful work.

:-D

ok, I try to explain my copy/paste decisions a bit:

First I search a opensource app on fdroid to look into the "equilzer" code, because another issue describes the system-wide equilizer as 'it is easy' (?). I found https://github.com/iamSahdeep/Bop with a "to complex" equlizer and decide to take a look into the "visualizer" code. Surprise! There is a lib for that! ... but after hours of work and try to fix: the lib eplainations does not work!!!

hm. What happend? I look to the expaination how to add to the dependencies and the sample code description. After doing this everything seams to work. But: App crashed very early with some "DEX zip ... BarViritualizer not found". After a long time to fix it, I decided to look into the "bob app" code: Ups!

Because of the 2. point and the only magic in the code seams to come from android.media.audiofx.Visualizer I decide to include the lib code into my app by drag-and-dropping it from the zip-download into my intellij IDE:

Because of the inline code hints and inline license hints I had no hesitation in copying that.

After doing that:

The only bug I found: if the sound plays and the visualizer work, switching the dark/day theme crashes the App

I hope, I have not forgotten anything. maybe you have use the new 28 appcombat

no-go commented 5 years ago

The only bug I found: if the sound plays and the visualizer work, switching the dark/day theme crashes the App

The trick to fix this bug: doing release for recreate() in the 2 action items:

 ...
 item.setChecked(false);
 mPreferences.edit().putBoolean("is_dark", false).apply();
 getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
 barVisualizer.release();
 recreate();
no-go commented 5 years ago

Hi. A friend test a modified App and got an "App crash issue" on changing to night/day mode.

I only fix this by a real "app close and reopen":

...
 item.setChecked(false);
 mPreferences.edit().putBoolean("is_dark", false).commit();
 getDelegate().setLocalNightMode(AppCompatDelegate.MODE_NIGHT_NO);
 Intent mStartActivity = new Intent(this, WebRadio.class);
 int mPendingIntentId = 123456;
 PendingIntent mPendingIntent = PendingIntent.getActivity(this, mPendingIntentId, mStartActivity, PendingIntent.FLAG_CANCEL_CURRENT);
 AlarmManager mgr = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
 mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 500, mPendingIntent);
 System.exit(0);

Not a good solution :-S and the +500ms feels like 3sec

Starcommander commented 5 years ago

No, the solution is not good! To find the reason of app crash we need a log-output. With android-sdk you can connect the phone, and enter "adb logcat" to get the logs. Then you should be able to find an exception or a stack trace for this issue. (look at the timestamps)

(An other way is to just drop the visualizer that needs accu-power and additional permission)

no-go commented 5 years ago

I know about the logging, but without the device which result in that crash issue, it is impossible :-S

I did not even know, if it is the result of the visualizer or a "recreate()" issue special on android 9.