|
|
@ -6,6 +6,7 @@ import android.content.Context; |
|
|
import android.content.Intent; |
|
|
import android.content.Intent; |
|
|
import android.media.MediaPlayer; |
|
|
import android.media.MediaPlayer; |
|
|
import android.net.Uri; |
|
|
import android.net.Uri; |
|
|
|
|
|
import android.os.Build; |
|
|
import android.os.Bundle; |
|
|
import android.os.Bundle; |
|
|
import android.os.Debug; |
|
|
import android.os.Debug; |
|
|
import android.os.Handler; |
|
|
import android.os.Handler; |
|
|
@ -32,16 +33,11 @@ import androidx.recyclerview.widget.GridLayoutManager; |
|
|
import com.alibaba.android.arouter.facade.annotation.Route; |
|
|
import com.alibaba.android.arouter.facade.annotation.Route; |
|
|
import com.alibaba.android.arouter.launcher.ARouter; |
|
|
import com.alibaba.android.arouter.launcher.ARouter; |
|
|
import com.google.gson.Gson; |
|
|
import com.google.gson.Gson; |
|
|
import com.iflytek.cloud.ErrorCode; |
|
|
|
|
|
import com.iflytek.cloud.InitListener; |
|
|
|
|
|
import com.iflytek.cloud.RecognizerListener; |
|
|
|
|
|
import com.iflytek.cloud.RecognizerResult; |
|
|
|
|
|
import com.iflytek.cloud.SpeechConstant; |
|
|
|
|
|
import com.iflytek.cloud.SpeechError; |
|
|
|
|
|
import com.iflytek.cloud.SpeechRecognizer; |
|
|
|
|
|
import com.iflytek.cloud.SpeechUtility; |
|
|
|
|
|
import com.iflytek.sparkchain.core.asr.ASR; |
|
|
import com.iflytek.sparkchain.core.asr.ASR; |
|
|
import com.iflytek.sparkchain.core.asr.AsrCallbacks; |
|
|
import com.iflytek.sparkchain.core.asr.AsrCallbacks; |
|
|
|
|
|
import com.iflytek.sparkchain.core.asr.Segment; |
|
|
|
|
|
import com.iflytek.sparkchain.core.asr.Transcription; |
|
|
|
|
|
import com.iflytek.sparkchain.core.asr.Vad; |
|
|
import com.shockman.sm.vendor.IHttp; |
|
|
import com.shockman.sm.vendor.IHttp; |
|
|
import com.shockman.sm.vendor.SmUtils; |
|
|
import com.shockman.sm.vendor.SmUtils; |
|
|
import com.shockman.sm.vendor.TargetVo; |
|
|
import com.shockman.sm.vendor.TargetVo; |
|
|
@ -101,7 +97,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
static final int TYPE_HINT_PASSWORD = 3;//隐藏密码输入框
|
|
|
static final int TYPE_HINT_PASSWORD = 3;//隐藏密码输入框
|
|
|
static final int TYPE_START_SERVER = 4;//重新启动web服务
|
|
|
static final int TYPE_START_SERVER = 4;//重新启动web服务
|
|
|
static String HtmlUrl = "http://127.0.0.1:8080/index.html";//webServer服务地址 http://192.168.1.218:5173/
|
|
|
static String HtmlUrl = "http://127.0.0.1:8080/index.html";//webServer服务地址 http://192.168.1.218:5173/
|
|
|
//static String HtmlUrl = "http://192.168.1.196:5500/index.html";
|
|
|
|
|
|
|
|
|
//static String HtmlUrl = "http://192.168.1.196:5173/";
|
|
|
int time = 0; |
|
|
int time = 0; |
|
|
private VideoView currentVideo; |
|
|
private VideoView currentVideo; |
|
|
SocketClient localSocketClient; |
|
|
SocketClient localSocketClient; |
|
|
@ -278,7 +274,9 @@ public class WebViewActivity extends BaseActivity { |
|
|
currentVideo.setVisibility(View.GONE); |
|
|
currentVideo.setVisibility(View.GONE); |
|
|
currentVideo.clearAnimation(); |
|
|
currentVideo.clearAnimation(); |
|
|
currentVideo = nextVideo; |
|
|
currentVideo = nextVideo; |
|
|
currentVideo.start(); |
|
|
|
|
|
|
|
|
if (!currentVideo.isPlaying()) { |
|
|
|
|
|
currentVideo.start(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
@Override |
|
|
@Override |
|
|
public void onAnimationRepeat(Animation animation) {} |
|
|
public void onAnimationRepeat(Animation animation) {} |
|
|
@ -295,6 +293,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
Log.e("WebViewActivity", "setData"); |
|
|
Log.e("WebViewActivity", "setData"); |
|
|
WebSettings webSettings = binding.web.getSettings(); |
|
|
WebSettings webSettings = binding.web.getSettings(); |
|
|
webSettings.setJavaScriptEnabled(true); |
|
|
webSettings.setJavaScriptEnabled(true); |
|
|
|
|
|
webSettings.setDomStorageEnabled(true); |
|
|
webSettings.setUseWideViewPort(true); |
|
|
webSettings.setUseWideViewPort(true); |
|
|
webSettings.setLoadWithOverviewMode(true); |
|
|
webSettings.setLoadWithOverviewMode(true); |
|
|
webSettings.setSupportZoom(false); |
|
|
webSettings.setSupportZoom(false); |
|
|
@ -302,10 +301,16 @@ public class WebViewActivity extends BaseActivity { |
|
|
webSettings.setDisplayZoomControls(false); |
|
|
webSettings.setDisplayZoomControls(false); |
|
|
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); |
|
|
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); |
|
|
webSettings.setAllowFileAccess(true); |
|
|
webSettings.setAllowFileAccess(true); |
|
|
webSettings.setJavaScriptCanOpenWindowsAutomatically(true); |
|
|
|
|
|
webSettings.setLoadsImagesAutomatically(true); |
|
|
webSettings.setLoadsImagesAutomatically(true); |
|
|
webSettings.setDefaultTextEncodingName("utf-8"); |
|
|
webSettings.setDefaultTextEncodingName("utf-8"); |
|
|
webSettings.setUserAgentString(""); |
|
|
webSettings.setUserAgentString(""); |
|
|
|
|
|
webSettings.setMediaPlaybackRequiresUserGesture(false); // 允许自动播放
|
|
|
|
|
|
|
|
|
|
|
|
// 适配HTTPS/HTTP混合内容
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { |
|
|
|
|
|
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//加载web
|
|
|
//加载web
|
|
|
currRoute = Constant.ROUTE_WEB_VIEW; |
|
|
currRoute = Constant.ROUTE_WEB_VIEW; |
|
|
loadH5Url(getIntent().getBooleanExtra(Constant.KEY_LOAD_H5_URL, false)); |
|
|
loadH5Url(getIntent().getBooleanExtra(Constant.KEY_LOAD_H5_URL, false)); |
|
|
@ -478,16 +483,11 @@ public class WebViewActivity extends BaseActivity { |
|
|
if("sbc".equals(Constant.TTSFac)) { |
|
|
if("sbc".equals(Constant.TTSFac)) { |
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\":\"/tts/stop\"}")); |
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\":\"/tts/stop\"}")); |
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\":\"/asr/start\"}")); |
|
|
localSocketClient.send(StringUtil.strSplice("{\"method\":\"/asr/start\"}")); |
|
|
runOnUiThread(new Runnable() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void run() { |
|
|
|
|
|
changeVideo("bg"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}else{ |
|
|
}else{ |
|
|
if(isrun){ |
|
|
if(isrun){ |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
ttsUtil.stopTTs(); |
|
|
if(mAsr == null){ |
|
|
if(mAsr == null){ |
|
|
LoggerUtil.d(TAG, "未初始化"); |
|
|
LoggerUtil.d(TAG, "未初始化"); |
|
|
initASR(); |
|
|
initASR(); |
|
|
@ -500,6 +500,12 @@ public class WebViewActivity extends BaseActivity { |
|
|
isrun = true; |
|
|
isrun = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
runOnUiThread(new Runnable() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void run() { |
|
|
|
|
|
changeVideo("bg"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
// h5调用android:停止识别语音
|
|
|
// h5调用android:停止识别语音
|
|
|
@JavascriptInterface |
|
|
@JavascriptInterface |
|
|
@ -633,7 +639,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
runOnUiThread(new Runnable() { |
|
|
runOnUiThread(new Runnable() { |
|
|
@Override |
|
|
@Override |
|
|
public void run() { |
|
|
public void run() { |
|
|
binding.web.loadUrl(StringUtil.strSplice("javascript:window.youAskOver('"+"');")); |
|
|
|
|
|
|
|
|
binding.web.evaluateJavascript("javascript: window.youAskOver('');", null); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
stopAsr(); |
|
|
stopAsr(); |
|
|
@ -650,7 +656,7 @@ public class WebViewActivity extends BaseActivity { |
|
|
runOnUiThread(new Runnable() { |
|
|
runOnUiThread(new Runnable() { |
|
|
@Override |
|
|
@Override |
|
|
public void run() { |
|
|
public void run() { |
|
|
binding.web.loadUrl(StringUtil.strSplice("javascript:window.youAskOver('"+"');")); |
|
|
|
|
|
|
|
|
binding.web.evaluateJavascript("javascript: window.youAskOver('');", null); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|