Skip to content

Commit c3b521c

Browse files
author
Paul Ruiz
committed
Added Ford App Link Audio Demo
1 parent 53a57fc commit c3b521c

File tree

1 file changed

+13
-2
lines changed
  • FordAppLinkAudio/fordapplinkaudio/src/main/java/com/ptrprograms/fordapplinkaudio/Service

1 file changed

+13
-2
lines changed

FordAppLinkAudio/fordapplinkaudio/src/main/java/com/ptrprograms/fordapplinkaudio/Service/AppLinkService.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ public void onOnHMIStatus(OnHMIStatus onHMIStatus) {
158158
break;
159159
}
160160
case NOT_AUDIBLE: {
161-
stopAudio();
161+
if( mPlayer != null )
162+
stopAudio();
162163
break;
163164
}
164165
}
@@ -180,14 +181,21 @@ private void playAudio() {
180181
if( mPlayer == null )
181182
mPlayer = new MediaPlayer();
182183

184+
try {
185+
mProxy.show("Loading audio stream...", "", TextAlignment.CENTERED, mCorrelationId++);
186+
} catch( SyncException e ) {}
187+
183188
mPlayer.reset();
184189
mPlayer.setAudioStreamType( AudioManager.STREAM_MUSIC );
185190
try {
186191
mPlayer.setDataSource(url);
187192
mPlayer.setOnPreparedListener( new MediaPlayer.OnPreparedListener() {
188193
@Override
189-
public void onPrepared(MediaPlayer mediaPlayer) {
194+
public void onPrepared( MediaPlayer mediaPlayer ) {
190195
mediaPlayer.start();
196+
try {
197+
mProxy.show("Playing online audio", "", TextAlignment.CENTERED, mCorrelationId++);
198+
} catch( SyncException e ) {}
191199
}
192200
});
193201
mPlayer.prepare();
@@ -202,6 +210,9 @@ private void stopAudio() {
202210
if( mPlayer == null )
203211
mPlayer = new MediaPlayer();
204212
mPlayer.pause();
213+
try {
214+
mProxy.show("Press OK", "to play audio", TextAlignment.CENTERED, mCorrelationId++);
215+
} catch( SyncException e ) {}
205216
}
206217

207218
private void subscribeToButtons() {

0 commit comments

Comments
 (0)