TUI-ConsoleLauncher icon indicating copy to clipboard operation
TUI-ConsoleLauncher copied to clipboard

Music crash

Open mistrysiddh opened this issue 6 years ago • 5 comments

App get crashed when I use music command.

mistrysiddh avatar Jan 20 '20 02:01 mistrysiddh

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

RationalG avatar Jan 22 '20 16:01 RationalG

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

mistrysiddh avatar Jan 23 '20 05:01 mistrysiddh

same here, same blackberry model.

arkenoi avatar Feb 06 '20 10:02 arkenoi

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.

RationalG avatar Feb 09 '20 00:02 RationalG

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....

ki11base avatar Oct 10 '20 10:10 ki11base