2013-03-20 2 views
1

나는 오래된 질문을 알고 있지만 나는 옳은 대답을 찾을 수 없습니다. MMS를 통해 내 동영상을 공유하고 싶지만이 오류가 계속 발생합니다. "연결할 수 없습니다. 파일 지원 안됨" 다음안드로이드에서 mms 인 텐트를 통해 비디오를 공유하십시오.

내 코드 먼저 내 녹화 클래스이며, 두 번째는 비디오 플레이어입니다 :

public class VideoComponent extends Activity { 
    private SurfaceHolder surfaceHolder; 
    private SurfaceView surfaceView; 
    public MediaRecorder mrec = new MediaRecorder(); 
    private Button startRecording = null; 
    private Button stopRecording = null; 
    private Button play = null; 
    private Button gallery = null; 
    int BytesPerElement = 2; 

    File video; 
    private Camera mCamera; 
    File audiofile = null; 
    boolean recording=false; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main1); 

     startRecording = (Button)findViewById(R.id.buttonstart); 
     stopRecording = (Button)findViewById(R.id.share); 
     play=(Button)findViewById(R.id.play); 
     gallery= (Button)findViewById(R.id.gallery); 


     mCamera = Camera.open(); 
     surfaceView = (SurfaceView) findViewById(R.id.surface_camera); 


     surfaceHolder = surfaceView.getHolder(); 


     surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); 
     startRecording.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       try { 
        if(recording==false) 
         startRecording(); 

       } catch (IOException e) { 
        Log.i("test" , "Video Not starting"); 

       } 

      } 
     }); 
     stopRecording.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 


        recording=false; 
        stopRecording(); 

      } 
     }); 
     play.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       Intent i= new Intent(getApplicationContext(),VideoPlayer.class); 
       i.putExtra("URI", audiofile.getAbsolutePath()); 
       startActivity(i); 
      } 
     }); 

     gallery.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       Intent i= new Intent(getApplicationContext(),Gallery.class); 
       startActivity(i); 
      } 
     }); 


    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) 
    { 
      Log.i("Test" , "Menu thing"); 
     menu.add(0, 0, 0, "StartRecording"); 
     menu.add(0, 1, 0, "StopRecording"); 
     return true; 
    } 

    @Override 
    public boolean onOptionsItemSelected(MenuItem item) 
    { 
     switch (item.getItemId()) 
     { 
     case 0: 
      try { 
        Log.i("Test" , "Start Recording"); 
       startRecording(); 
      } catch (Exception e) { 
       String message = e.getMessage(); 
       Log.i("Self", "Problem Start"+message); 
       mrec.release(); 
      } 
      break; 

     case 1: //GoToAllNotes 
      mrec.stop(); 
      mrec.release(); 
      mrec = null; 
      break; 

     default: 
      break; 
     } 
     return super.onOptionsItemSelected(item); 
    } 

    public void startRecording() throws IOException 
    { 
     recording=true; 
     String path= Environment.getExternalStorageDirectory().toString(); 
     File sampleDir = new File(path+"/DCIM/Camera"); 
     sampleDir.mkdir(); 


     Log.i("Setting Path", sampleDir.toString()); 

      try { 
       audiofile = File.createTempFile("Video", ".3gp", sampleDir); 
      } catch (IOException e) { 

       return;} 
      int minBufferSize = AudioRecord.getMinBufferSize(8000, 
       AudioFormat .CHANNEL_IN_MONO, 
       AudioFormat.ENCODING_PCM_16BIT); 
     mrec = new MediaRecorder(); // Works well 

     mCamera.unlock(); 
     mrec.setCamera(mCamera); 

     mrec.setPreviewDisplay(surfaceHolder.getSurface()); 
     mrec.setVideoSource(MediaRecorder.VideoSource.CAMERA); 
     mrec.setAudioSource(MediaRecorder.AudioSource.MIC); 
     mrec.setMaxDuration(60000); 
     mrec.setAudioSamplingRate(16000); 
     mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); 
     mrec.setPreviewDisplay(surfaceHolder.getSurface()); 
     mrec.setOutputFile(audiofile.getAbsolutePath()); 
     mrec.prepare(); 
     mrec.start(); 


    } 

    protected void stopRecording() { 
     mrec.stop(); 
     mrec.release(); 
     mCamera.lock(); 
     mCamera.release(); 
     Log.i("testing","going to call Destroyer"); 
     //surfaceDestroyed(surfaceHolder); 

     //mCamera.stopPreview(); 


     //finish(); 
    } 

    private void releaseMediaRecorder(){ 
     Log.i("testing","re;ease Media record"); 
     if (mrec != null) { 
      mrec.reset(); // clear recorder configuration 
      mrec.release(); // release the recorder object 
      mrec = null; 
      mCamera.lock();   // lock camera for later use 
     } 
    } 

    private void releaseCamera(){ 
      Log.i("testing","re;ease Camera"); 
     if (mCamera != null){ 
      mCamera.release();  // release the camera for other applications 
      mCamera = null; 
     } 
    } 
} 

이 내 비디오 플레이어 클래스

public class VideoPlayer extends Activity { 
VideoView videoView; 
Button mms=null; 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 

    //Create a VideoView widget in the layout file 
    //use setContentView method to set content of the activity to the layout file which contains videoView 
    this.setContentView(R.layout.video); 
    final Intent i= getIntent(); 
    final String uri=i.getStringExtra("URI"); 
    Log.i("URI","Path is"+Uri.parse(uri)); 

    mms=(Button)findViewById(R.id.mms); 

    videoView = (VideoView)this.findViewById(R.id.videoView1); 

    //add controls to a MediaPlayer like play, pause. 
    MediaController mc = new MediaController(this); 
    videoView.setMediaController(mc); 

    //Set the path of Video or URI 
    videoView.setVideoURI(Uri.parse(uri)); 

    //Set the focus 
    videoView.requestFocus(); 
    videoView.start(); 


    mms.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      Intent i = new Intent(Intent.ACTION_SEND); 
      i.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity"); 
      i.putExtra(Intent.EXTRA_STREAM,Uri.parse(uri)); 
      i.setType("video/*"); 
      startActivity(i); 
     } 
    }); 
} 
} 

매니페스트 파일

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.videoplayer" 
android:versionCode="1" 
android:versionName="1.0" > 

<uses-sdk 
    android:minSdkVersion="10" 
    android:targetSdkVersion="17" /> 

<uses-permission android:name="android.permission.RECORD_AUDIO" /> 
<uses-permission android:name="android.permission.CAMERA" /> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
<uses-feature android:name="android.hardware.camera.autofocus" /> 
<uses-feature android:name="android.hardware.camera" /> 
<application android:icon="@drawable/icon" 
    android:label="@string/app_name" 
     android:debuggable="true"> 
    <activity android:name=".VideoComponent" 
       android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 
      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 
    </activity> 
    <activity android:name=".VideoPlayer" 
       android:label="@string/app_name"> 
     <intent-filter> 
      <action android:name="android.intent.action.SEND" /> 
    <category android:name="android.intent.category.DEFAULT" /> 
    <data android:mimeType="*/*" /> 
     </intent-filter> 
    </activity> 
    <activity android:name=".VideoRecorder" 
       android:label="@string/app_name"> 

    </activity> 
    <activity android:name=".Gallery" 
       android:label="@string/app_name"> 
    </activity> 
</application> 
</manifest> 

입니다 편집 : 파일 형식은 .3gp입니다. 그것이 이메일을 위해 일하고 있기 때문에 경로에 문제 없습니다. EDIT # 2 : 전체 코드 첨부 동영상의 URI를 올바르게 전달하는 데 문제가 있는지 확인하십시오.

Intent i = new Intent(Intent.ACTION_SEND); 
       i.setClassName("com.android.mms", "com.android.mms.ui.ComposeMessageActivity"); 
       i.putExtra("Hi ", "Please find attachment"); 
       i.putExtra(Intent.EXTRA_STREAM,uri); 
       i.setType("video/*"); 
       startActivity(Intent.createChooser(i, "Share via")); 

날 상태를 알려 :

답변

0

이 코드를하려고 의도

아래
  ArrayList<Uri> imageUris = new ArrayList<Uri>(); 
      for (int i = 0; i < checkeditem.size(); i++) { 
       File file = new File(RecordService.DEFAULT_STORAGE_LOCATION,checkeditem.get(i).toString()); 
       Log.i("Share Media ","Sending is file is " + file.toString()); 
       imageUris.add(Uri.fromFile(file)); 
      } 
      // (3) to share multiple file in URi use below code here 
      Intent shareIntent = new Intent(); 
      shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); 
      shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,imageUris); 
      shareIntent.setType("*/*"); 
      startActivity(Intent.createChooser(shareIntent, "Share with")); 
+0

작동하지 않으며 동일한 결과를 제공합니다. 내가 갤러리 메시지 나 Facebook에서 직접 공유하려고 할 때도 괜찮습니다. 그래서 내 코드에 문제가 있음을 의미합니다. –

0

처럼하려고합니다.

+0

작동하지 않으며 동일한 결과를 제공합니다. 내가 갤러리 메시지 나 Facebook에서 직접 공유하려고 할 때도 괜찮습니다. 그래서 내 코드에 문제가 있음을 의미합니다. –

+0

이 코드는 페이스 북이나 기타의 기본 응용 프로그램에 연결됩니다. 나는 잘못이 귀하의 모바일 mms라고 생각합니다. –

+0

모바일 mms는 갤러리에서 직접 공유하려고하면 잘 작동하기 때문에 괜찮습니다. 심지어 수동으로 안드로이드 전화의 메시징 응용 프로그램을 열 때 그것을 잘 작동 mms이 비디오를 첨부합니다. 이 코드를 잘 확인하십시오. 또는 다른 곳에서 문제가있을 수 있음을 시사합니다. –

관련 문제