안드로이드 개발 질문/답변
(글 수 45,052)
안녕하세요.
rtsp://주소/xxx.mp4 형식의 영상을 플레이 할수 있는 앱을 개발중입니다.
MediaPlayer사용 하라고 하실거 같아서 말씀 드리자면
앱을 구동할 기기가 일반 폰이 아니라 안드로이드 기반의 PMP입니다.
해서 기기가 rtsp를 정상지원하지 못합니다.
이런 이유로 영상으로 다운로드 하여 저장후 플레이 하는 방식을 취하려고 합니다.
아래와 같이 서버의 파일을 로컬로 저장 하도록 간단히 구성을 하였습니다.
path2의 주소는 rtsp://xxxx.com/xxx/xxx.mp4 의 형식입니다.
try{ URL url = new URL("path2); URLConnection conn = url.openConnection(); conn.connect(); InputStream is = conn.getInputStream(); if ( is == null ){ Log.d(TAG, "Input Stream data is null"); } Log.d(TAG, is.toString()); File tmp = File.createTempFile("cam", "dat"); tmp.deleteOnExit(); String tmpFile = tmp.getAbsolutePath(); FileOutputStream os = new FileOutputStream(tmp); filePath = tmpFile; byte buff[] = new byte[1024]; do { int nRead = is.read(buff); if ( nRead <= 0 ) break; os.write(buff); Log.d(TAG, "buff == " + buff); } while(true); try { is.close(); } catch ( Exception e ){ e.printStackTrace(); } } catch ( Exception e ){ e.printStackTrace(); }
위 소스를 실행하면 rtsp프로토콜을 알수 없다고 합니다.
rtsp프로토콜로 파일을 받아 올수 있는 방법이 없을까요?