마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

rtsp에서 비디오뷰 질문입니다.

0 추천
package com.example.videoplayer;

import java.io.IOException;
import java.net.URL;

import android.app.Activity;
import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

public class Player extends Activity {
 

//rtsp path
 public String path = "@@@@@@";
 private VideoView v;
 private TextView tv;
 private TextView log;
 //MediaPlayer mp;
 public String name;
 
 //스트리밍 받을 url입력
// private static final String URL_string =

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_player);
  Uri mUri = Uri.parse("rtsp");
  MediaMetadataRetriever mr = new MediaMetadataRetriever();
  
  Log.d("a","%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
  mr.setDataSource(getApplicationContext(), mUri);
  
  //mr.setDataSource
  Log.d("b", "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  
  //mr.setDataSource(path);
  //mp = new MediaPlayer();
  //mr.setDataSource(getApplicationContext(), mUri);
 /* try {
   
   
  } catch (IllegalArgumentException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (SecurityException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IllegalStateException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } */

  MediaController mc = new MediaController(this);
  v = (VideoView) findViewById(R.id.videoView1);
  log = (TextView) findViewById(R.id.log);
  
  v.setMediaController(mc);
  v.setVideoURI(Uri.parse(path));
  tv = (TextView) findViewById(R.id.URL);
  tv.setText(path);

 // tv.setText(mp.MEDIA_MIMETYPE_TEXT_SUBRIP);
  name = mr.extractMetadata((mr.METADATA_KEY_VIDEO_HEIGHT));
  //tv.setText(mr.extractMetadata(mr.METADATA_KEY_VIDEO_WIDTH));
  
  log.setText(name);
  

 
  v.start();
  
  
  
 
 
  /*v.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
  
    
    ((VideoView) v).start();
   }
  });*/
  
  
 }
 
 @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // Inflate the menu; this adds items to the action bar if it is present.
  getMenuInflater().inflate(R.menu.player, menu);
  return true;
 }

}

 

10-10 15:21:28.270: E/AndroidRuntime(28247): FATAL EXCEPTION: main
10-10 15:21:28.270: E/AndroidRuntime(28247): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.videoplayer/com.example.videoplayer.Player}: android.content.res.Resources$NotFoundException: String resource ID #0x7
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.app.ActivityThread.access$700(ActivityThread.java:140)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1237)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.os.Looper.loop(Looper.java:137)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.app.ActivityThread.main(ActivityThread.java:4946)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at java.lang.reflect.Method.invokeNative(Native Method)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at java.lang.reflect.Method.invoke(Method.java:511)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1036)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:803)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at dalvik.system.NativeStart.main(Native Method)
10-10 15:21:28.270: E/AndroidRuntime(28247): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.content.res.Resources.getText(Resources.java:250)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.widget.TextView.setText(TextView.java:3795)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at com.example.videoplayer.Player.onCreate(Player.java:65)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.app.Activity.performCreate(Activity.java:5206)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
10-10 15:21:28.270: E/AndroidRuntime(28247):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
10-10 15:21:28.270: E/AndroidRuntime(28247):  ... 11 more
홍성재 (260 포인트) 님이 2013년 10월 10일 질문
홍성재님이 2013년 10월 18일 수정

1개의 답변

0 추천

: Caused by:android.content.res.Resources$NotFoundException: String resource ID #0x7

aucd29 (218,390 포인트) 님이 2013년 10월 11일 답변
...