Commit 9aef0478 authored by Martin LOISEAU's avatar Martin LOISEAU 🎄
Browse files

Improve tts logic

parent d263de5c
......@@ -36,7 +36,7 @@ public class MainActivity extends AppCompatActivity {
MediaPlayer mp;
SpeechRecognizer sr;
GoogleApiAvailability m_gga;
TTSReader ttsreader;
public TTSReader ttsreader;
//game logic
public List<Atom> Atoms;
......
......@@ -30,4 +30,9 @@ public final class TTSReader { // basically a static class
return true;
}
public boolean isOver()
{
return(!tts.isSpeaking());
}
}
......@@ -5,8 +5,11 @@ import com.example.qrquest.MainActivity;
public abstract class Action {
MainActivity mainActivity;
public boolean isOver;
public Action(MainActivity mainActivity)
{
isOver = false;
this.mainActivity = mainActivity;
}
......
package com.example.qrquest.actions;
import com.example.qrquest.MainActivity;
public class CaptureQR extends Action {
/*
* This action will open the camera to let the user scan a QR code
* It will add the scanned QR code as a new atom
*/
public CaptureQR(MainActivity mainActivity) {
super(mainActivity);
}
public void Do()
{
// open QRCaptureActivity here and wait for its result
}
}
......@@ -2,6 +2,7 @@ package com.example.qrquest.actions;
import android.speech.tts.TextToSpeech;
import com.example.qrquest.MainActivity;
import com.example.qrquest.TTSReader;
public class TTSReading extends Action {
TextToSpeech tts;
......@@ -17,6 +18,9 @@ public class TTSReading extends Action {
public void Do()
{
// read TextToRead
mainActivity.ttsreader.PlayTTS(TextToRead);
while(!mainActivity.ttsreader.isOver()) {} // block while speaking
isOver = true; // release when over
}
}
......@@ -35,6 +35,7 @@ public class Node {
for (Action a: Actions
) {
a.Do();
while(!a.isOver{ };
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment