@@ -211,8 +211,7 @@ private void playSpecificEpisode() {
211
211
if (videos .size () == 1 ) {
212
212
playVideo (videos .get (0 ));
213
213
} else {
214
- doToast ("Sorry, I found more than one match. Try to be more specific?" );
215
- GoogleSearchApi .speak (context , "Sorry, I found more than one match. Try to be more specific?" );
214
+ feedback ("Sorry, I found more than one match. Try to be more specific?" );
216
215
}
217
216
}
218
217
@@ -257,8 +256,7 @@ private void doEpisodeSearch(String queryTerm, final String season, final String
257
256
Log .v (MainActivity .TAG , "Found shows: " + shows .size ());
258
257
259
258
if (shows .size () == 0 ) {
260
- GoogleSearchApi .speak (context , "Sorry, I couldn't find " + queryTerm );
261
- Log .e (TAG , "Sorry, I couldn't find " + queryTerm );
259
+ feedback ("Sorry, I couldn't find " + queryTerm );
262
260
} else if (shows .size () == 1 ) {
263
261
PlexDirectory show = shows .get (0 );
264
262
Log .v (TAG , "Show key: " + show .getKey ());
@@ -288,8 +286,7 @@ public void onSuccess(String response) {
288
286
289
287
if (foundSeason == null ) {
290
288
Log .e (TAG , "Sorry, I couldn't find that season." );
291
- GoogleSearchApi .speak (context , "Sorry, I couldn't find that season." );
292
- doToast ("Sorry, I couldn't find that season." );
289
+ feedback ("Sorry, I couldn't find that season." );
293
290
} else {
294
291
try {
295
292
String url = "http://" + server .getIPAddress () + ":" + server .getPort () + "" + foundSeason .getKey ();
@@ -318,8 +315,7 @@ public void onSuccess(String response) {
318
315
}
319
316
Log .v (TAG , "foundEpisode = " + foundEpisode );
320
317
if (foundEpisode == false ) {
321
- GoogleSearchApi .speak (context , "Sorry, I couldn't find that episode." );
322
- doToast ("Sorry, I couldn't find that episode." );
318
+ feedback ("Sorry, I couldn't find that episode." );
323
319
}
324
320
}
325
321
});
@@ -376,7 +372,7 @@ public void onSuccess(String response) {
376
372
377
373
private void onFinishedLatestEpisodeSearch (String queryTerm ) {
378
374
if (videos .size () == 0 ) {
379
- GoogleSearchApi . speak ( context , "Sorry, I couldn't find " + queryTerm );
375
+ feedback ( "Sorry, I couldn't find " + queryTerm );
380
376
} else {
381
377
// For now, just take the first one
382
378
playVideo (videos .get (0 ));
@@ -432,19 +428,23 @@ private void onMovieSearchFinished(String queryTerm) {
432
428
433
429
if (chosenVideo != null ) {
434
430
Log .v (MainActivity .TAG , "Chosen video: " + chosenVideo .getTitle ());
435
- GoogleSearchApi . speak ( context , "Now watching " + chosenVideo .getTitle () + " on " + client .getName ());
431
+ feedback ( "Now watching " + chosenVideo .getTitle () + " on " + client .getName ());
436
432
437
433
playVideo (chosenVideo );
438
434
} else {
439
435
Log .v (MainActivity .TAG , "Didn't find a video" );
440
- GoogleSearchApi .speak (context , "Sorry, I couldn't find a video to play." );
441
- doToast ("Sorry, I couldn't find a video to play." );
436
+ feedback ("Sorry, I couldn't find a video to play." );
442
437
}
443
438
}
444
439
445
- private void doToast (String text ) {
446
- Toast .makeText (context , text , Toast .LENGTH_SHORT ).show ();
440
+ private void feedback (String text ) {
441
+ if (mPrefs .getInt ("feedback" , MainActivity .FEEDBACK_VOICE ) == MainActivity .FEEDBACK_VOICE ) {
442
+ GoogleSearchApi .speak (context , text );
443
+ } else {
444
+ Toast .makeText (context , text , Toast .LENGTH_SHORT ).show ();
445
+ }
447
446
}
447
+
448
448
private void playVideo (PlexVideo video ) {
449
449
try {
450
450
String url = "http://" + client .getHost () + ":" + client .getPort () + "/player/playback/playMedia?machineIdentifier=" + server .getMachineIdentifier () + "&key=" + video .getKey ();
0 commit comments