Sms Gratis Indosat

Phone Numbers
0 -
Example : 83832867987 Without 0

Type your Messages

Question: + =

Crying wallpaper, free wallpaper pictures

Crying wallpaper, free wallpaper pictures, wallpapers backgrounds free, free desktops wallpaper, crying wallpapers, free desktops, free easter wallpaper











Crying girl wallpaper, crying girl wallpapers

Crying girl wallpaper, crying girl wallpapers, girls on wallpaper, girls in wallpaper, girls free wallpaper, new sad girls wallpapers, girls girls wallpapers











Get the current frame in VideoView using MediaMetadataRetriever

Last exercise show a simple example to "Get image frame in video using MediaMetadataRetriever". In this exercise, we will play the video in a VideoView. Then capture the frame at the position when user click on the button.

Get the current frame in VideoView using MediaMetadataRetriever


layout file.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<Button
android:id="@+id/capture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="capture video image" />
<VideoView
android:id="@+id/videoview"
android:layout_width="match_parent"
android:layout_height="match_parent" />

</LinearLayout>


MainActivity.java
package com.example.androidvideoview;

import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;

public class MainActivity extends Activity {

MediaMetadataRetriever mediaMetadataRetriever;
MediaController myMediaController;
VideoView myVideoView;
String viewSource = "/storage/sdcard0/DCIM/100MEDIA/VIDEO0009.mp4";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

mediaMetadataRetriever = new MediaMetadataRetriever();
mediaMetadataRetriever.setDataSource(viewSource);

myVideoView = (VideoView) findViewById(R.id.videoview);
myVideoView.setVideoURI(Uri.parse(viewSource));
myMediaController = new MediaController(this);
myVideoView.setMediaController(myMediaController);

myVideoView.setOnCompletionListener(myVideoViewCompletionListener);
myVideoView.setOnPreparedListener(MyVideoViewPreparedListener);
myVideoView.setOnErrorListener(myVideoViewErrorListener);

myVideoView.requestFocus();
myVideoView.start();

Button buttonCapture = (Button)findViewById(R.id.capture);
buttonCapture.setOnClickListener(new OnClickListener(){

@Override
public void onClick(View arg0) {

int currentPosition = myVideoView.getCurrentPosition(); //in millisecond
Toast.makeText(MainActivity.this,
"Current Position: " + currentPosition + " (ms)",
Toast.LENGTH_LONG).show();

Bitmap bmFrame = mediaMetadataRetriever
.getFrameAtTime(currentPosition * 1000); //unit in microsecond

if(bmFrame == null){
Toast.makeText(MainActivity.this,
"bmFrame == null!",
Toast.LENGTH_LONG).show();
}else{
AlertDialog.Builder myCaptureDialog =
new AlertDialog.Builder(MainActivity.this);
ImageView capturedImageView = new ImageView(MainActivity.this);
capturedImageView.setImageBitmap(bmFrame);
LayoutParams capturedImageViewLayoutParams =
new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
capturedImageView.setLayoutParams(capturedImageViewLayoutParams);

myCaptureDialog.setView(capturedImageView);
myCaptureDialog.show();
}

}});
}

MediaPlayer.OnCompletionListener myVideoViewCompletionListener =
new MediaPlayer.OnCompletionListener() {

@Override
public void onCompletion(MediaPlayer arg0) {
Toast.makeText(MainActivity.this, "End of Video",
Toast.LENGTH_LONG).show();
}
};

MediaPlayer.OnPreparedListener MyVideoViewPreparedListener =
new MediaPlayer.OnPreparedListener() {

@Override
public void onPrepared(MediaPlayer mp) {

long duration = myVideoView.getDuration(); //in millisecond
Toast.makeText(MainActivity.this,
"Duration: " + duration + " (ms)",
Toast.LENGTH_LONG).show();

}
};

MediaPlayer.OnErrorListener myVideoViewErrorListener =
new MediaPlayer.OnErrorListener() {

@Override
public boolean onError(MediaPlayer mp, int what, int extra) {

Toast.makeText(MainActivity.this,
"Error!!!",
Toast.LENGTH_LONG).show();
return true;
}
};

}


Note: To use MediaMetadataRetriever, minSdkVersion="10" have to be defined in AndroidManifest.xml.

Get image frame in video using MediaMetadataRetriever

MediaMetadataRetriever, for API level 10 or higher, provides a unified interface for retrieving frame and meta data from an input media file.

Example to retrieve frame in video:

retrieve frame in video


package com.example.androidmediametadataretriever;

import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.os.Bundle;
import android.widget.ImageView;
import android.app.Activity;

public class MainActivity extends Activity {

String uri = "/storage/sdcard0/DCIM/100MEDIA/VIDEO0007.mp4";

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView capturedImageView = (ImageView)findViewById(R.id.capturedimage);

MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever();

mediaMetadataRetriever.setDataSource(uri);
Bitmap bmFrame = mediaMetadataRetriever.getFrameAtTime(5000000); //unit in microsecond
capturedImageView.setImageBitmap(bmFrame);
}

}


Next:
- Get the current frame in VideoView using MediaMetadataRetriever


Creative wallpaper, desktop creative wallpaper

Creative wallpaper, desktop creative wallpaper, wallpaper store, decorative wallpaper, wallpaper and borders, wallpaper books, backgrounds, wallpaper home, wallpaper world











 
Copyright © 2015. About - Web Version - Mobile Version Sitemap - Contact - Privacy