@@ -488,10 +488,12 @@ private void init() {
488
488
showWearPurchase = false ;
489
489
showWearPurchase ();
490
490
}
491
- logger .d ("Intent action: %s" , getIntent ().getAction ());
491
+ logger .d ("(init) Intent action: %s" , getIntent ().getAction ());
492
492
Intent intent = getIntent ();
493
493
if (intent .getAction () != null && getIntent ().getAction ().equals (ACTION_SHOW_NOW_PLAYING )) {
494
- handleShowNowPlayingIntent (getIntent ());
494
+ handleShowNowPlayingIntent (intent );
495
+ } else if (intent .getAction ().equals (com .atomjack .shared .Intent .ACTION_PLAY_LOCAL )) { // this intent will only arrive when playing music. playing video will go to VideoPlayerActivity
496
+ handlePlayLocalIntent (intent );
495
497
} else {
496
498
497
499
logger .d ("Loading main fragment" );
@@ -1228,36 +1230,7 @@ protected void onNewIntent(final Intent intent) {
1228
1230
} else if (intent .getAction ().equals (ACTION_SHOW_NOW_PLAYING )) {
1229
1231
handleShowNowPlayingIntent (intent );
1230
1232
} else if (intent .getAction ().equals (com .atomjack .shared .Intent .ACTION_PLAY_LOCAL )) { // this intent will only arrive when playing music. playing video will go to VideoPlayerActivity
1231
- logger .d ("Binding to LocalMusicService" );
1232
- bindMusicPlayerService ();
1233
- final PlexTrack track = intent .getParcelableExtra (com .atomjack .shared .Intent .EXTRA_MEDIA );
1234
- final ArrayList <? extends PlexMedia > playlist = intent .getParcelableArrayListExtra (com .atomjack .shared .Intent .EXTRA_PLAYLIST );
1235
- logger .d ("Got track %s and media container with %d tracks" , (track != null ? track .title : null ), playlist .size ());
1236
- if (musicPlayerFragment != null && musicPlayerFragment .isVisible ()) {
1237
- localMusicService .setTrack (track );
1238
- localMusicService .setPlaylist (playlist );
1239
- localMusicService .reset ();
1240
- localMusicService .playSong ();
1241
- } else {
1242
- musicConnection .setOnConnected (new Runnable () {
1243
- @ Override
1244
- public void run () {
1245
- localMusicService .setTrack (track );
1246
- localMusicService .setPlaylist (playlist );
1247
- localMusicService .reset ();
1248
- localMusicService .playSong ();
1249
-
1250
- setCastIconActive ();
1251
- if (musicPlayerFragment == null )
1252
- musicPlayerFragment = new MusicPlayerFragment ();
1253
-
1254
- musicPlayerFragment .init (localMusicService .getTrack (), localMusicService .getPlaylist ());
1255
- logger .d ("Switching to music" );
1256
- switchToFragment (musicPlayerFragment );
1257
- }
1258
- });
1259
- }
1260
-
1233
+ handlePlayLocalIntent (intent );
1261
1234
} else if (intent .getAction () != null && intent .getAction ().equals (com .atomjack .shared .Intent .SHOW_WEAR_PURCHASE )) {
1262
1235
// An Android Wear device was successfully pinged, so show popup alerting the
1263
1236
// user that they can purchase wear support, but only if we've never shown the popup before.
@@ -1313,6 +1286,38 @@ private void onFirstTimeScanFinished() {
1313
1286
doAutomaticDeviceScan ();
1314
1287
}
1315
1288
1289
+ private void handlePlayLocalIntent (Intent intent ) {
1290
+ logger .d ("Binding to LocalMusicService" );
1291
+ bindMusicPlayerService ();
1292
+ final PlexTrack track = intent .getParcelableExtra (com .atomjack .shared .Intent .EXTRA_MEDIA );
1293
+ final ArrayList <? extends PlexMedia > playlist = intent .getParcelableArrayListExtra (com .atomjack .shared .Intent .EXTRA_PLAYLIST );
1294
+ logger .d ("Got track %s and media container with %d tracks" , (track != null ? track .title : null ), playlist .size ());
1295
+ if (musicPlayerFragment != null && musicPlayerFragment .isVisible ()) {
1296
+ localMusicService .setTrack (track );
1297
+ localMusicService .setPlaylist (playlist );
1298
+ localMusicService .reset ();
1299
+ localMusicService .playSong ();
1300
+ } else {
1301
+ musicConnection .setOnConnected (new Runnable () {
1302
+ @ Override
1303
+ public void run () {
1304
+ localMusicService .setTrack (track );
1305
+ localMusicService .setPlaylist (playlist );
1306
+ localMusicService .reset ();
1307
+ localMusicService .playSong ();
1308
+
1309
+ setCastIconActive ();
1310
+ if (musicPlayerFragment == null )
1311
+ musicPlayerFragment = new MusicPlayerFragment ();
1312
+
1313
+ musicPlayerFragment .init (localMusicService .getTrack (), localMusicService .getPlaylist ());
1314
+ logger .d ("Switching to music" );
1315
+ switchToFragment (musicPlayerFragment );
1316
+ }
1317
+ });
1318
+ }
1319
+ }
1320
+
1316
1321
private void handleShowNowPlayingIntent (Intent intent ) {
1317
1322
client = intent .getParcelableExtra (com .atomjack .shared .Intent .EXTRA_CLIENT );
1318
1323
PlexMedia media = intent .getParcelableExtra (com .atomjack .shared .Intent .EXTRA_MEDIA );
0 commit comments