アプリのメイン タブに、2 番目のアクティビティを介して URL からビデオを起動しようとするボタンがあります。
空白のアクティビティでテストしたところ、ボタンがクリックされたときに「こんにちは」が正常に表示されました。次に、別の同様の投稿で提案されているように、「Hello」編集テキストを削除し、Java ファイルにコードを追加しました。
ビデオ ボタンをクリックすると、「このビデオを再生できません、OK」というメッセージが表示されます。
私はすでにYouTubeリンクをテストしましたが、これは有効なリンクです。それでもlogcatエラーメッセージには次のものが含まれます:
10-07 09:04:36.785: I/MediaPlayer(11397): path is null
10-07 09:04:36.795: D/MediaPlayer(11397): setDataSource IOException happend :
10-07 09:04:36.795: D/MediaPlayer(11397):
java.io.FileNotFoundException: No content provider: http://youtu.be/RFrg1xFoxeQ
ここからどこへ行けばいいですか?
2 番目のアクティビティの XML は次のとおりです。
<VideoView
android:id="@+id/videoView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</TableLayout>
対応Javaファイル
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_serve_motion_up_together);
String videoPath2 = "http://youtu.be/RFrg1xFoxeQ";
VideoView videoView1 = (VideoView) findViewById(R.id.videoView1);
videoView1.setVideoURI(Uri.parse(videoPath2));
videoView1.setMediaController(new MediaController(this));
videoView1.setVisibility(1);
videoView1.bringToFront();
videoView1.requestFocus();
videoView1.start();
}
ログキャット
10-07 09:04:36.765: D/dalvikvm(11397): GC_CONCURRENT freed 97K, 12% free 9619K/10887K, paused 13ms+2ms, total 47ms
10-07 09:04:36.785: V/MediaPlayer(11397): constructor
10-07 09:04:36.785: V/MediaPlayer(11397): setListener
10-07 09:04:36.785: I/MediaPlayer(11397): path is null
10-07 09:04:36.795: D/MediaPlayer(11397): setDataSource IOException happend :
10-07 09:04:36.795: D/MediaPlayer(11397): java.io.FileNotFoundException: No content provider: http://youtu.be/RFrg1xFoxeQ
10-07 09:04:36.795: D/MediaPlayer(11397): at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:710)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:614)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.media.MediaPlayer.setDataSource(MediaPlayer.java:929)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.widget.VideoView.openVideo(VideoView.java:235)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.widget.VideoView.access$2000(VideoView.java:51)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.widget.VideoView$6.surfaceCreated(VideoView.java:478)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.SurfaceView.updateWindow(SurfaceView.java:591)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.SurfaceView.access$000(SurfaceView.java:81)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:173)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:707)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1944)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1113)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4481)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.Choreographer.doFrame(Choreographer.java:525)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.os.Handler.handleCallback(Handler.java:615)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.os.Handler.dispatchMessage(Handler.java:92)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.os.Looper.loop(Looper.java:137)
10-07 09:04:36.795: D/MediaPlayer(11397): at android.app.ActivityThread.main(ActivityThread.java:4867)
10-07 09:04:36.795: D/MediaPlayer(11397): at java.lang.reflect.Method.invokeNative(Native Method)
10-07 09:04:36.795: D/MediaPlayer(11397): at java.lang.reflect.Method.invoke(Method.java:511)
10-07 09:04:36.795: D/MediaPlayer(11397): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1007)
10-07 09:04:36.795: D/MediaPlayer(11397): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:774)
10-07 09:04:36.795: D/MediaPlayer(11397): at dalvik.system.NativeStart.main(Native Method)
10-07 09:04:36.795: D/MediaPlayer(11397): Couldn't open file on client side, trying server side
10-07 09:04:36.795: V/MediaPlayer(11397): setVideoSurfaceTexture
10-07 09:04:36.795: V/MediaPlayer(11397): MediaPlayer::setAudioStreamType
10-07 09:04:36.795: V/MediaPlayer(11397): setVideoSurfaceTexture
10-07 09:04:36.795: V/MediaPlayer(11397): prepareAsync
10-07 09:04:36.825: D/ProgressBar(11397): setProgressDrawable mProgressDrawable = null, d = android.graphics.drawable.LayerDrawable@41b6d730needUpdate = false
10-07 09:04:36.825: D/ProgressBar(11397): setProgress = 0
10-07 09:04:36.825: D/ProgressBar(11397): setProgress = 0, fromUser = false
10-07 09:04:36.825: D/ProgressBar(11397): mProgress = 0mIndeterminate = false, mMin = 0, mMax = 100
10-07 09:04:36.835: W/ResourceType(11397): Failure getting entry for 0x010802c9 (t=7 e=713) in package 0 (error -75)
10-07 09:04:36.935: E/SpannableStringBuilder(11397): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
10-07 09:04:36.935: E/SpannableStringBuilder(11397): SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
10-07 09:04:40.699: V/MediaPlayer(11397): message received msg=100, ext1=1, ext2=-2147483648
10-07 09:04:40.699: E/MediaPlayer(11397): error (1, -2147483648)
10-07 09:04:40.699: V/MediaPlayer(11397): callback application
10-07 09:04:40.699: V/MediaPlayer(11397): back from callback
10-07 09:04:40.699: E/MediaPlayer(11397): Error (1,-2147483648)
10-07 09:04:40.699: D/VideoView(11397): Error: 1,-2147483648
10-07 09:04:40.719: W/ResourceType(11397): Failure getting entry for 0x010802c9 (t=7 e=713) in package 0 (error -75)
ティア
CCH4ADT