2012-02-03 10 views

答えて

5

ストリーミングのために以下の方法で外部ビデオプレーヤーを起動することもできます。利用可能なビデオプレーヤーのリストを表示し、自分が選んだプレーヤーを選択できます。

private static void executeIntentForplayVideo(String localPath, 
     LTDCommonData ltdCommonData, final Context activity) { 

    final Intent intent = new Intent(); 
    intent.setAction(android.content.Intent.ACTION_VIEW); 
    // Stream from remote path 
    intent.setDataAndType(Uri.parse(finalPath), "video/*"); 
    //play from sd-card 
    // intent.setDataAndType(Uri.fromFile(file), "video/*"); 
    try { 
     List<ResolveInfo> intents = activity.getPackageManager() 
     .queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); 
     if (intents != null && intents.size() > 0) { 

      activity.startActivity(intent); 

     } else { 
      Toast toast = Toast.makeText(activity,"Please download a video player" , Toast.LENGTH_SHORT); 
      toast.show(); 

     } 
    } catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 
関連する問題