Note that there are some explanatory texts on larger screens.

plurals
  1. POshare video through mms intent in android
    primarykey
    data
    text
    <p>I know its an old questions but i just cannot find the right answer. I want to share my video Via MMS, but i keep on getting this error "Unable to attach. File Not supported".</p> <p>Following is my Code First is my Recording class and second one is the video Player:</p> <pre><code>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; } } } </code></pre> <p>this is my Video Player class</p> <pre><code>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); } }); } } </code></pre> <p>Manifest File</p> <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.videoplayer" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="10" android:targetSdkVersion="17" /&gt; &lt;uses-permission android:name="android.permission.RECORD_AUDIO" /&gt; &lt;uses-permission android:name="android.permission.CAMERA" /&gt; &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt; &lt;uses-feature android:name="android.hardware.camera.autofocus" /&gt; &lt;uses-feature android:name="android.hardware.camera" /&gt; &lt;application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"&gt; &lt;activity android:name=".VideoComponent" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".VideoPlayer" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.SEND" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;data android:mimeType="*/*" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;activity android:name=".VideoRecorder" android:label="@string/app_name"&gt; &lt;/activity&gt; &lt;activity android:name=".Gallery" android:label="@string/app_name"&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>EDIT: File Format is .3gp. Not Problem with path since it is working for Email. EDIT # 2: Complete code is attached please check if there is some problem in passing uri of the video correctly.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload