2011-08-10 24 views
1

我目前有一個webview,當你按下mp3鏈接時,mp3就會開始播放。我們最近更改了所有鏈接,現在它們是「https」而不是「http」。我從我的日誌貓收到的錯誤如下:Android-從url鏈接啓動mp3

08-09 17:26:59.060: ERROR/AndroidRuntime(5574): FATAL EXCEPTION: main 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://s3.amazonaws.com/StopDropRave/Week+of+August+8/Flawless+ft.+Army+of+Karmen+-+L.I.E.+%28Love+Automatic+Dubstep+Remix%29.mp3 typ=audio/* } 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1409) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1379) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at android.app.Activity.startActivityFromChild(Activity.java:3067) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at android.app.Activity.startActivityForResult(Activity.java:2847) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at android.app.Activity.startActivity(Activity.java:2933) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at ravebox.dev.sdr.BlogActivity$HelloWebViewClient$1.onClick(BlogActivity.java:158) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:159) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at android.os.Handler.dispatchMessage(Handler.java:99) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at android.os.Looper.loop(Looper.java:123) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at android.app.ActivityThread.main(ActivityThread.java:3835) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at java.lang.reflect.Method.invokeNative(Native Method) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at java.lang.reflect.Method.invoke(Method.java:507) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 
08-09 17:26:59.060: ERROR/AndroidRuntime(5574):  at dalvik.system.NativeStart.main(Native Method) 

我不知道它是因爲https還是不是。不知道。有任何想法嗎?感謝

這是我這個特殊的活動清單的一部分:

<activity android:name=".BlogActivity" 
        android:label="@string/app_name" 
        android:screenOrientation="portrait"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.DEFAULT" /> 
      </intent-filter> 
     </activity> 

而且,這裏是我的代碼,我處理聽力部分的一部分。它基本上打開一個對話框,用戶可以選擇收聽或下載。下載工作完美,但在將鏈接更改爲https後聽不到。

private class HelloWebViewClient extends WebViewClient { 
     @Override 
     public boolean shouldOverrideUrlLoading(final WebView view, 
       final String url) { 
      view.loadUrl(url); 
      view.getSettings().getAllowFileAccess(); 
      view.getSettings().setJavaScriptEnabled(true); 
      view.getCertificate(); 
      // load the dropbox files so people can listen to the track 
      if (url.startsWith("https://") && url.endsWith(".mp3")) { 
       view.getCertificate(); 
       progressWebView.dismiss(); 
       progressWebView.cancel(); 
       /*blogDialog.setButton("Listen", 
         new DialogInterface.OnClickListener() { 
          @Override 
          public void onClick(DialogInterface dialog, 
            int which) { 
           Intent intent = new Intent(Intent.ACTION_VIEW); 
           intent.setDataAndType(Uri.parse(url), "audio/*"); 
           view.getContext().startActivity(intent); 

          } 
         });*/ 
       blogDialog.setButton2("Download", 
         new DialogInterface.OnClickListener() { 
          @Override 
          public void onClick(DialogInterface dialog, 
            int which) { 
           sdrUrl = url.toString(); 
           new DownloadFile().execute(); 

          } 

         }); 
       blogDialog.show(); 

      } else { 
       return super.shouldOverrideUrlLoading(view, url); 
      } 
      return true; 
     } 
    } 
+0

在將鏈接更改爲https之前測試了回放嗎? – Deepak

+0

@Deepak:是的,一切都很完美。沒有任何問題。 – Splitusa

+0

你能檢查你的Manifest文件的意圖過濾器嗎?看起來篩選器與您想要播放的數據和類型不匹配?檢查您的過濾器的某些部分是否使用了「http://」硬編碼。 – Deepak

回答

0

SergioRa, 看起來你有「BlogActivity」從你試圖播放任何音頻文件。 默認情況下,Android音樂播放器應用程序將用於播放鏈接中的數據。 音樂播放器應用程序中的Streaming播放器活動僅將數據方案設置爲「http」,因此不會使用「https」方案播放新鏈接中的內容。

SO早已這樣的查詢和這裏是鏈接,problem in streaming audio from https link

這就是爲什麼下載工作正常,但播放沒有的原因。 所以我建議你在播放之前將文件下載到設備上的臨時位置。