Android 4.x RemoteControlClient.setTransportControlFlags() not working? - android

I'm trying to use the RemoteControlClient class to support the lock screen player with my app. One issue is that setting the transport control flags seems like they don't work properly.
For example I'm trying to just show a play/stop icon no prev/next:
mRemoteControlClient.setTransportControlFlags(
RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE |
RemoteControlClient.FLAG_KEY_MEDIA_STOP);
This shows a previous icon and pause icon! Why?
To make things even worse when pressing the stop/play button you only receive KEYCODE_MEDIA_PLAY_PAUSE when you should be getting KEYCODE_MEDIA_STOP or KEYCODE_MEDIA_PLAY.
This is frustrating poor development on Android side if I find out I'm doing this correctly.

The FLAG_KEY_MEDIA_STOP never shows stop because of bug in android as reported here:
https://code.google.com/p/android/issues/detail?id=29920
If you use the flag PLAY_PAUSE is should not produce a KEYCODE_MEDIA_STOP event. Why would it?
It is a play/pause toggle action that does what it is intended to. It is up to your application to store the state of your media player.
If I understand the documentation correctly you could get KEYCODE_MEDIA_PLAY or KEYCODE_MEDIA_PAUSE only if you use the flags FLAG_KEY_MEDIA_PLAY and FLAG_KEY_MEDIA_PAUSE.
But android might be "clever" and translate it to a toggle.
I'm not sure about that.

Use the FLAG_KEY_MEDIA_PLAY_PAUSE
oRemoteControlClient.setTransportControlFlags(RemoteControlClient.FLAG_KEY_MEDIA_PLAY_PAUSE);
And lie to the RemoteControlClient ;-)
Tell him the stream is buffering and it will show the stop button!
oRemoteControlClient.setPlaybackState(RemoteControlClient.PLAYSTATE_BUFFERING);
Cheers

Related

Android MediaSession: How to choose the icons shown on lock screen?

I have an app that plays media via MediaSessionCompat.
I create a notification for the Notification Drawer using NotificationCompat and post it using NotificationManagerCompat.notify, and it looks great. (See screenshot.)
My problem is with the lock screen. It only shows Play, Previous Track, and Next Track icons. I'm missing the controls to jump back and forward within the currently playing track. (See screenshot.)
I'm using MediaSession.setPlaybackState to specify the actions that are available, and I am including all the appropriate ones from PlaybackStateCompat for rewind, fast forward, skip to previous, and skip to next.
Is the lock screen configured differently than the notification? Or do developers simply have less control over the controls provided here?
Thank you in advance!

Android TV - resume already started content from home

I am new to Android TV programming and just managed to have an App that starts a video from an ExoPlayer implementation.
When I hit the HOME-button the home is shown and the content I started appears in the purple marked area. I can resume my App from here.
TV Emulator - Android 10
Can you tell me how this area is called?
How can I control which meta data is shown?
I only found information about the Watch Next Card, but it seems to be something different.
That seems to be the notification area. It's not exclusive to playback.
For example, notifications for a firmware update will also appear there.
To have a proper now playing car and display metadata and other info see this:
https://developer.android.com/training/tv/playback/now-playing.html

Android Invisible Remote Views

So I am building a media player app and need some direction from anyone who knows.
Since I am forced to show a notificaiton, just to control lock screen wallpaper back to android 4 I am wonder now, if a remote view has the ability to be Visibility>INVISIBLE OR GONE.
This question is mainly just to get a yes or no answer from someone who make know since I am short on time now and don't wanna chase after something that may not be possible.

Volume slider while casting

I need to show the volume slider while casting an audio content to a Chromecast remote.
If I put the app to the background the slider is shown (see this).
The problem is that the framework does not show the slider when the app is not in the background.I guess it is because an application can decide to do something else.
I have tried to call
mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, AudioManager.ADJUST_SAME, AudioManager.FLAG_SHOW_UI);
with no success: the slider that is shown does not have the Chromecast icon and does not report the current volume on the remote. In other words the slider is related with the local audio volume.
is there a way to ask the framework to keep showing the slider even when the app is in the foreground?
Edited
Actually the behaviour even with the VideoCast app is a bit inconsistent. On some phones it is enough to bring the app in the background and make the framework showing the volume slider. After that it will keep showing it even when the app is in the foreground. On other phones this does not work or it is not necessary because the slider is shown correctly.
There is a bit of improvement that can be made; when media is playing back (i.e. if it is not on pause), you can achieve what you want. To see how, you need to override onKeyDown; take a look at the CastVideos-android sample, in class VideoBrowserActivity and try that to see if it does what you'd like or not.
Since you want to show the Chromecast control instead of the generic music control, you need to call:
mAudioManager.adjustSuggestedStreamVolume(AudioManager.ADJUST_SAME,
AudioManager.USE_DEFAULT_STREAM_TYPE, AudioManager.FLAG_SHOW_UI);

Any way to hide Android home screen icons to show Live Wallpaper?

As Android live wallpapers are becoming more prevalent, and developers are doing more with them, a question coming up more and more is how to hide the home screen icons temporarily while the user interacts with the wallpaper.
For this to work, the icons would have to be removed temporarily – not just made invisible, since a tap on an invisible icon would still run the app.
Also, it would be ideal to have a universal solution that works across customs launchers, not just the Android stock launcher.
This question was already asked on StackOverflow, and the answer was that you cannot do this. But this is clearly not correct, as there are at least two programs on Android Market that do exactly this: Show Off (Your Live Wallpaper) and The Cleaner (Show Wallpaper)
Is there a way to hide Android home screen icons, and then later put them back in place?
You can launch an activty which backgroung will be your live walpaper, and finish the activty upon touch... Just a thought...
Edit:
1st comment answer:
Preventing the delay:
You should be more "gentle" in the onCreate() method...
Try creating the minimum as possible in the onCreate(), like, just displaying the basic background...
in the end of the onCreate function, set an alarm (i.e. by AlarmManager) to call some BroadcastReceiver/Activity after half a second or so (with AlarmManager) to set the rest of the live wallpaper graphics... that way you don't have to worry about the delay.
This would have to be a completely new launcher. This is not possible without this I don't think. Sorry. However; to be absolutely sure though you'd have to look at the Launcher2 package in the android source and look through files like Homescreen.java. I'll look into it later on 2.3.3 for you and see what I find.
Try using the zoom gesture as you would to zoom in on a web page (reverse pinch). And you guessed it, the opposite makes everything come back.

Categories

Resources