2017-05-20 13 views
0

にロードされたとき、私はボタンをクリックしたときにそれがうまく機能は動作しません:ResponsiveVoiceは、ページがアンドロイドのWebViewの

<!DOCTYPE html> 
 
<html> 
 
<head> 
 

 

 
    <script src="https://code.responsivevoice.org/responsivevoice.js"></script> 
 

 
    </head > 
 

 
<body> 
 

 
<button onclick="responsiveVoice.speak('Welcome to the Responsive Voice website');">Click</button> 
 

 
</body> 
 
</html>

が、私はときに、ページのスピーチを再生したいときは動作しません。

<!DOCTYPE html> 
<html> 
<head> 

    <script src="https://code.responsivevoice.org/responsivevoice.js"></script> 

    </head > 

<body> 

<script> 

    setTimeout(responsiveVoice.speak("Welcome to the Responsive Voice website"),500); 

</script> 
</body> 
</html> 

のAndroidコード:

0123のWebViewにロードされています

マニフェストファイル:

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.abdallah.test"> 

    <WebView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/webview" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     /> 

    <uses-permission android:name="android.permission.INTERNET"/> 
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <activity android:name=".MainActivity"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 

</manifest> 

私はボタンをクリックすると、これは、システムのログです:私は、ページがロードされたときにスピーチを再生したいとき

I/chromium: [INFO:CONSOLE(62)] "Voice support NOT ready", source: https://code.responsivevoice.org/responsivevoice.js (62) 
I/chromium: [INFO:CONSOLE(62)] "Voice support NOT ready", source: https://code.responsivevoice.org/responsivevoice.js (62) 
I/chromium: [INFO:CONSOLE(62)] "Voice support NOT ready", source: https://code.responsivevoice.org/responsivevoice.js (62) 
I/chromium: [INFO:CONSOLE(63)] "RV: speechSynthesis present but no system voices found", source: https://code.responsivevoice.org/responsivevoice.js (63) 
I/chromium: [INFO:CONSOLE(64)] "RV: Enabling fallback mode", source: https://code.responsivevoice.org/responsivevoice.js (64) 
D/MediaResourceGetter: ethernet/wifi connection detected 
D/MediaHTTPConnection: filterOutInternalHeaders: key=User-Agent, val= SonyD5803 Build/23.4.A.1.232 stagefright/1.2 (Linux;Android 5.1.1) 
D/MediaHTTPConnection: proxy null port 0 
D/MediaResourceGetter: resource doesn't have video 
D/MediaResourceGetter: extracted valid metadata: MediaMetadata[durationInMilliseconds=0, width=0, height=0, success=true] 
E/MediaPlayer-JNI: QCMediaPlayer mediaplayer NOT present 
D/MediaPlayer: Couldn't open file on client side, trying server side 
D/MediaHTTPConnection: filterOutInternalHeaders: key=User-Agent, val= SonyD5803 Build/23.4.A.1.232 stagefright/1.2 (Linux;Android 5.1.1) 
D/MediaHTTPConnection: filterOutInternalHeaders: key=allow-cross-domain-redirect, val= false 
D/MediaHTTPConnection: filterOutInternalHeaders: key=x-wap-profile, val= http://uaprof.sonymobile.com/D5803R2321.xml 
D/MediaHTTPConnection: proxy null port 0 
E/MediaPlayer: Should have subtitle controller already set 
D/MediaPlayer: getMetadata 

これは、次のとおりです。

I/chromium: [INFO:CONSOLE(62)] "Voice support NOT ready", source: https://code.responsivevoice.org/responsivevoice.js (62) 
I/chromium: [INFO:CONSOLE(62)] "Voice support NOT ready", source: https://code.responsivevoice.org/responsivevoice.js (62) 
I/chromium: [INFO:CONSOLE(62)] "Voice support NOT ready", source: https://code.responsivevoice.org/responsivevoice.js (62) 
I/chromium: [INFO:CONSOLE(62)] "Voice support NOT ready", source: https://code.responsivevoice.org/responsivevoice.js (62) 
I/chromium: [INFO:CONSOLE(62)] "Voice support NOT ready", source: https://code.responsivevoice.org/responsivevoice.js (62) 
I/chromium: [INFO:CONSOLE(63)] "RV: speechSynthesis present but no system voices found", source: https://code.responsivevoice.org/responsivevoice.js (63) 
I/chromium: [INFO:CONSOLE(64)] "RV: Enabling fallback mode", source: https://code.responsivevoice.org/responsivevoice.js (64) 
D/MediaResourceGetter: ethernet/wifi connection detected 
D/MediaHTTPConnection: filterOutInternalHeaders: key=User-Agent, val= SonyD5803 Build/23.4.A.1.232 stagefright/1.2 (Linux;Android 5.1.1) 
D/MediaHTTPConnection: proxy null port 0 
D/MediaResourceGetter: resource doesn't have video 
D/MediaResourceGetter: extracted valid metadata: MediaMetadata[durationInMilliseconds=0, width=0, height=0, success=true] 

答えて

0

ResponsiveVoiceさんのコメント:

iOSでは、音声合成などのいくつかのイベントは、ユーザー操作(つまり、クリック)。そのため、ResponsiveVoiceは、たとえばページの読み込みでは動作しない呼び出しを発声します。

音声合成では、そのユーザーがトリガした操作は一度だけ行う必要があります。最初のコール以降の直接コールは、期待通りに機能します。

したがって、ユーザーがクリックできるように「開始」ボタンを追加し、それをresponsiveVoice.speak()の初期化呼び出しとして使用することをお勧めします。その呼び出しには、必要に応じてテキストとして空白を入れることができるため、ユーザーに影響はありません。

私はアンドロイドが同じだと思うが、私は私の問題への解決策を見つけた:

最初に私がスピーチへのテキストのためのJavaScript関数を含むHTMLページをロードします。 次に、次のコードのように関数自体をロードします。

final Handler handler=new Handler(); 
handler.postDelayed(new Runnable() { 

         public void run() { 
          WebView webView = (WebView) findViewById(R.id.myWebview); 
          webView.loadUrl("javascript:speak('" + s + "');"); 

         } 
        }, 5000);