我一直在尝试从远程 url/dailymotion 播放 mp4 视频。我已经从其他网站播放了 .3gp 格式的其他视频,效果很好,但无法在我的 Android 应用程序中播放日常运动中的任何视频,这是我的所有代码,无法理解问题。任何帮助
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<VideoView
android:id="@+id/VideoView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
`
公开课歌曲延伸 Activity {
String VideoURL = "http://www.dailymotion.com/video/x2trnoh_indian-girl-mehndi-dance_fun";
VideoView videoview;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Get the layout from video_main.xml
setContentView(R.layout.songs);
// Find your VideoView in your video_main.xml layout
videoview = (VideoView) findViewById(R.id.VideoView);
try {
// Start the MediaController
MediaController mediacontroller = new MediaController(
songs.this);
mediacontroller.setAnchorView(videoview);
// Get the URL from String VideoURL
Uri video = Uri.parse(VideoURL);
videoview.setMediaController(mediacontroller);
videoview.setVideoURI(video);
videoview.requestFocus();
videoview.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
videoview.start();
}
});
} catch (Exception e) {
System.out.println("Video Play Error :" + e.getMessage());
}
}}
最佳答案
ASAIK,我们无法在正常的 Android 视频 View 中播放 dailymotion 视频。所以,而不是视频 View ,为什么你不能尝试他们的 SDK here并将其呈现在 WebView 中。
Dailymotion 提供了一个基于 WebView 的 SDK,其中包含您轻松播放视频所需的所有技巧:
Github链接::dailymotion-sdk-android/
自述文件提供了一个简单的集成示例
希望对你有帮助
关于android - 无法从远程 url 在 android VIdeoview 中播放 mp4 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32095592/