fandreuz / TUI-ConsoleLauncher

Linux CLI Launcher for Android
Other
1.24k stars 257 forks source link

Music crash #297

Open mrfoxie opened 4 years ago

mrfoxie commented 4 years ago

App get crashed when I use music command.

RationalG commented 4 years ago

Same here. Once i enable the music command and restart tui, the launcher crash whenever i want to use music -play or music -select. I am using the Blackberry bbf100

mrfoxie commented 4 years ago

It's shows me songs by using music -ls but unable to play

arkenoi commented 4 years ago

same here, same blackberry model.

RationalG commented 4 years ago

Ok, I resolved the problem. By reading the first issue which has been opened before this one regarding music crash you will know what this is about. This is because the way T-UI builds notifications does not work with versions of Android 8.1 & 9.

Just include the following conditions inside those two methods written in MusicService.java :

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if(System.currentTimeMillis() - lastNotificationChange < 500 || songTitle == null || songTitle.length() == 0) return super.onStartCommand(intent, flags, startId);

        lastNotificationChange = System.currentTimeMillis();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            nm.createNotificationChannel(new NotificationChannel(NOTIFICATION_CHANNEL_ID_SERVICE, MainManager.MUSIC_SERVICE, NotificationManager.IMPORTANCE_DEFAULT));
        } else {
            startForeground(NOTIFY_ID, buildNotification(this.getApplicationContext(), songTitle));
        }

        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onPrepared(MediaPlayer mp) {
        if(songTitle == null || songTitle.length() == 0) return;

        lastNotificationChange = System.currentTimeMillis();

        mp.start();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            nm.createNotificationChannel(new NotificationChannel(NOTIFICATION_CHANNEL_ID_SERVICE, MainManager.MUSIC_SERVICE, NotificationManager.IMPORTANCE_DEFAULT));
        } else {
            startForeground(NOTIFY_ID, buildNotification(this.getApplicationContext(), songTitle));
        }
    }

NOTIFICATION_CHANNEL_ID_SERVICE being "ohi.andre.consolelauncher.managers.music". Just declare the property.

After re-building and installing the .apk it worked. Music is played, no crash. I would have liked to see a music status bar displayed on the top part of the console with the rest of the informations but nothing shows up.

ki11base commented 4 years ago

Ok, I resolved the problem. By reading the first issue which has been opened before this one regarding music crash you will know what this is about. This is because the way T-UI builds notifications does not work with versions of Android 8.1 & 9.

Just include the following conditions inside those two methods written in MusicService.java :

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        if(System.currentTimeMillis() - lastNotificationChange < 500 || songTitle == null || songTitle.length() == 0) return super.onStartCommand(intent, flags, startId);

        lastNotificationChange = System.currentTimeMillis();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            nm.createNotificationChannel(new NotificationChannel(NOTIFICATION_CHANNEL_ID_SERVICE, MainManager.MUSIC_SERVICE, NotificationManager.IMPORTANCE_DEFAULT));
        } else {
            startForeground(NOTIFY_ID, buildNotification(this.getApplicationContext(), songTitle));
        }

        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onPrepared(MediaPlayer mp) {
        if(songTitle == null || songTitle.length() == 0) return;

        lastNotificationChange = System.currentTimeMillis();

        mp.start();
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
            nm.createNotificationChannel(new NotificationChannel(NOTIFICATION_CHANNEL_ID_SERVICE, MainManager.MUSIC_SERVICE, NotificationManager.IMPORTANCE_DEFAULT));
        } else {
            startForeground(NOTIFY_ID, buildNotification(this.getApplicationContext(), songTitle));
        }
    }

NOTIFICATION_CHANNEL_ID_SERVICE being "ohi.andre.consolelauncher.managers.music". Just declare the property.

After re-building and installing the .apk it worked. Music is played, no crash. I would have liked to see a music status bar displayed on the top part of the console with the rest of the informations but nothing shows up.

--------sad reply---------- What I need: How can I use that edited code to work on my android phone.

what happened: I downloaded the github tui launcher codes Oh man, I tried everything I could've think off, just like you said, but I've used notepad to edit the "overdrive part" and then I tried looking for a software that will convert "file to apk" nothing comes up (I wanted apk so that the edited file would work in phone right?) then I've tried using "android development kit" and didnt work and now it ask me to use gradle....