Android Question MediaPlayer car interface

Robert Valentino

Well-Known Member
Licensed User
I have taken the MediaPlayer example have it working and the music plays thru my car (I assume it is getting the music from the Bluetooth interface?)

When I press the Pause button on the cars touch screen after some time (there is some lag) my Media Player example pauses.

But the cars touch screen does not change the pause button to a play button and if I press pause again nothing seems to happen.

1) Can I catch the Pause command from my car and handle it?

2) Is there a way I can let the car know (or does it already and I need to mark the mediaplayer as paused) mediaplayer is paused?

3) Any way I can catch the Next and Back buttons?

ANY and I mean ANY help would be greatly appreciated.

Thanks

BobVal
 

Robert Valentino

Well-Known Member
Licensed User
OK, I guess I need to get the KeyCodes but how can I get KeyCodes when in a Service?

Is it possible to get KeyCodes in a Service? Get I get them if the service is in the Background running?
 

Robert Valentino

Well-Known Member
Licensed User
Running in debug mode (need to get car closer to house to see what is happening).

But I did notice that when I press the Pause button on the cars Touch Screen that a little Pause Icon appeared in my Samsungs S3 Status Bar. If I swipe down the status bar information I see a little (looks like a media player - that is scrolling song titles that are not being played). If I press the pause button in the Status bar it changes to a Play button but my software does not start again.

Any Ideas?

BobVal
 

Robert Valentino

Well-Known Member
Licensed User
Got closer to the car but Nothing shows up in the Unfiltered logs.

Not sure how to proceed. Something is happening but I am not sure how to figure out what.

Note: Include BroadcastReceiver:

B4X:
    Broadcast.Initialize("BroadcastReceiver")
    Broadcast.addAction("android.intent.action.MEDIA_BUTTON")	
   Broadcast.SetPriority(2147483647)
    Broadcast.registerReceiver("")
B4X:
Sub BroadcastReceiver_OnReceive(Action As String)

    #If Debug
    Log("BroadcastReceiver_OnReceive:[" &Action &"]")
	#End If
	
    ToastMessageShow(Action, False)
   
    'can only abort when sendOrderedbroadcast is called.
    'Broadcast.AbortBroadcast
End Sub
But do not see anything happening here
BobVal
 

Robert Valentino

Well-Known Member
Licensed User
Erel:

Read your posting on Intent Filters - Intercepting SMS messages in the background

Could something like that work for me? Not sure how to process the messages?

B4X:
AddPermission(android.permission.MEDIA_CONTENT_CONTROL)

AddReceiverText(s1, 
<intent-filter>
    <action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>)

What should I be looking for here??????????

B4X:
Sub Service_Start(startingIntent As Intent)

  If startingIntent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
      Dim messages() As Message
      messages = ParseSmsIntent(startingIntent)
      For i = 0 To messages.Length - 1
         Log(messages(i))
      Next
   End If
end sub
/code]
 

Robert Valentino

Well-Known Member
Licensed User
When my application is not paused I see the KeyCodes 87 (next) 88 (Previous) 127 (pause) and I assume I would see the 126 (play)

Problem is I never get ANY of these in a Service (I know cannot get KeyCodes in a Service). But have tried all the BroadcastReceiver ways (I know I must be doing something wrong)


BANG Head, BANG Head...

I am attaching my project maybe someone can tell me what I am doing wrong so that I can get these Media Keys


NOTE: I am using a Samsung S3 phone and my car is a 2011 Jeep Grand Cherokee

NOTE: In my program I am trying to make kind of a dj player where with 7 seconds left it starts another player and song so that one rolls into another (this all works real well)

NOTE: In the two MP3 zip files there are four MP3 files[2 in each] (chopped to 21 seconds so I can test the Segway from Player to another) these files need to be unzipped into need to be in \BOBs\MusicDB




Maybe I need to try a different attack.

Has ANYONE tried the Samsung MediaControl SDK. https://img-developer.samsung.com/contents/cmm/sms/MediaControlSDK_v1.0.4.zip

If someone has please let me know.

Thanks

BobVal
 

Attachments

Robert Valentino

Well-Known Member
Licensed User
Looking at some of the SDK code examples I am starting to think I need to handle MediaSession https://developer.android.com/reference/android/media/session/MediaSession.html
Playback States https://developer.android.com/reference/android/media/session/PlaybackState.html

Found this code.

B4X:
function playbackStateChange(event)
{
    log('playbackState: ' + event.playbackState);
}
vidPlayer.addEventListener('playbackState', playbackStateChange);

Think I better take a break. I am so far underwater and out of my league.

BobVal
 
Top