use of android.widget.VideoView in project AndroidSDK-RecipeBook by gabu.
the class Recipe086 method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode != RESULT_OK) {
// 正しい結果が得られなかった場合の処理
return;
}
if (requestCode == REQUEST_CODE_1) {
// このbitmapが撮影した画像データです。
Bitmap bitmap = (Bitmap) data.getExtras().get("data");
ImageView imageView = (ImageView) findViewById(R.id.image);
imageView.setImageBitmap(bitmap);
} else if (requestCode == REQUEST_CODE_2) {
// dataがnullなので、以下のように取得しないで
// Uri uri = data.getData();
// インテントにセットしたUri mPictureUriを使う
// エラーが発生していなければ、
// このmPictureUriに撮影した写真データのUriが入っている。
ImageView imageView = (ImageView) findViewById(R.id.image);
imageView.setImageURI(mPictureUri);
} else if (requestCode == REQUEST_CODE_3) {
// 撮影された動画のUriを取得
Uri uri = data.getData();
// VideoViewを取得
VideoView v = (VideoView) findViewById(R.id.VideoView01);
// VideoViewにはUriがセットできます。
v.setVideoURI(uri);
// 再生します。
v.start();
} else if (requestCode == REQUEST_CODE_4) {
// 録音された音声のUriを取得
Uri uri = data.getData();
// メディアプレーヤーで再生する例
MediaPlayer mp = new MediaPlayer();
try {
// Uriをセット
mp.setDataSource(getApplicationContext(), uri);
// 準備
mp.prepare();
// 再生!
mp.start();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} else if (requestCode == REQUEST_CODE_5) {
String resultStr = "";
// 認識結果のリストを取得
// 似ている言葉など、複数の結果がある場合もある。
List<String> results = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
for (String result : results) {
resultStr += (result + "\n");
}
TextView textView = (TextView) findViewById(R.id.text);
textView.setText(resultStr);
}
}
use of android.widget.VideoView in project android_frameworks_base by DirtyUnicorns.
the class VideoViewCaptureActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mVideoView = new VideoView(this);
mVideoView.setOnPreparedListener(mp -> {
mp.setLooping(true);
mVideoWidth = mp.getVideoWidth();
mVideoHeight = mp.getVideoHeight();
mVideoView.start();
});
Uri uri = Uri.parse("android.resource://com.android.test.hwui/" + R.raw.colorgrid_video);
mVideoView.setVideoURI(uri);
Button button = new Button(this);
button.setText("Copy bitmap to /sdcard/surfaceview.png");
button.setOnClickListener((View v) -> {
final Bitmap b = Bitmap.createBitmap(mVideoWidth, mVideoHeight, Bitmap.Config.ARGB_8888);
PixelCopy.request(mVideoView, b, (int result) -> {
if (result != PixelCopy.SUCCESS) {
Toast.makeText(VideoViewCaptureActivity.this, "Failed to copy", Toast.LENGTH_SHORT).show();
return;
}
try {
try (FileOutputStream out = new FileOutputStream(Environment.getExternalStorageDirectory() + "/surfaceview.png")) {
b.compress(Bitmap.CompressFormat.PNG, 100, out);
}
} catch (Exception e) {
// Ignore
}
}, mVideoView.getHandler());
});
FrameLayout content = new FrameLayout(this);
LinearLayout layout = new LinearLayout(this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(button, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layout.addView(mVideoView, LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
content.addView(layout, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT));
setContentView(content);
}
use of android.widget.VideoView in project DanmakuFlameMaster by Bilibili.
the class MainActivity method findViews.
private void findViews() {
mMediaController = findViewById(R.id.media_controller);
mBtnRotate = (Button) findViewById(R.id.rotate);
mBtnHideDanmaku = (Button) findViewById(R.id.btn_hide);
mBtnShowDanmaku = (Button) findViewById(R.id.btn_show);
mBtnPauseDanmaku = (Button) findViewById(R.id.btn_pause);
mBtnResumeDanmaku = (Button) findViewById(R.id.btn_resume);
mBtnSendDanmaku = (Button) findViewById(R.id.btn_send);
mBtnSendDanmakuTextAndImage = (Button) findViewById(R.id.btn_send_image_text);
mBtnSendDanmakus = (Button) findViewById(R.id.btn_send_danmakus);
mBtnRotate.setOnClickListener(this);
mBtnHideDanmaku.setOnClickListener(this);
mMediaController.setOnClickListener(this);
mBtnShowDanmaku.setOnClickListener(this);
mBtnPauseDanmaku.setOnClickListener(this);
mBtnResumeDanmaku.setOnClickListener(this);
mBtnSendDanmaku.setOnClickListener(this);
mBtnSendDanmakuTextAndImage.setOnClickListener(this);
mBtnSendDanmakus.setOnClickListener(this);
// VideoView
VideoView mVideoView = (VideoView) findViewById(R.id.videoview);
// DanmakuView
// 设置最大显示行数
HashMap<Integer, Integer> maxLinesPair = new HashMap<Integer, Integer>();
// 滚动弹幕最大显示5行
maxLinesPair.put(BaseDanmaku.TYPE_SCROLL_RL, 5);
// 设置是否禁止重叠
HashMap<Integer, Boolean> overlappingEnablePair = new HashMap<Integer, Boolean>();
overlappingEnablePair.put(BaseDanmaku.TYPE_SCROLL_RL, true);
overlappingEnablePair.put(BaseDanmaku.TYPE_FIX_TOP, true);
mDanmakuView = (IDanmakuView) findViewById(R.id.sv_danmaku);
mContext = DanmakuContext.create();
mContext.setDanmakuStyle(IDisplayer.DANMAKU_STYLE_STROKEN, 3).setDuplicateMergingEnabled(false).setScrollSpeedFactor(1.2f).setScaleTextSize(1.2f).setCacheStuffer(new SpannedCacheStuffer(), // 图文混排使用SpannedCacheStuffer
mCacheStufferAdapter).setMaximumLines(maxLinesPair).preventOverlapping(overlappingEnablePair);
if (mDanmakuView != null) {
mParser = createParser(this.getResources().openRawResource(R.raw.comments));
mDanmakuView.setCallback(new master.flame.danmaku.controller.DrawHandler.Callback() {
@Override
public void updateTimer(DanmakuTimer timer) {
}
@Override
public void drawingFinished() {
}
@Override
public void danmakuShown(BaseDanmaku danmaku) {
// Log.d("DFM", "danmakuShown(): text=" + danmaku.text);
}
@Override
public void prepared() {
mDanmakuView.start();
}
});
mDanmakuView.setOnDanmakuClickListener(new IDanmakuView.OnDanmakuClickListener() {
@Override
public boolean onDanmakuClick(IDanmakus danmakus) {
Log.d("DFM", "onDanmakuClick: danmakus size:" + danmakus.size());
BaseDanmaku latest = danmakus.last();
if (null != latest) {
Log.d("DFM", "onDanmakuClick: text of latest danmaku:" + latest.text);
return true;
}
return false;
}
@Override
public boolean onViewClick(IDanmakuView view) {
mMediaController.setVisibility(View.VISIBLE);
return false;
}
});
mDanmakuView.prepare(mParser, mContext);
mDanmakuView.showFPS(true);
mDanmakuView.enableDanmakuDrawingCache(true);
}
if (mVideoView != null) {
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.start();
}
});
mVideoView.setVideoPath(Environment.getExternalStorageDirectory() + "/1.flv");
}
}
use of android.widget.VideoView in project Small by wequick.
the class VideoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
VideoView videoView = (VideoView) findViewById(R.id.video_view);
final String uri = "android.resource://" + getPackageName() + "/" + R.raw.fix_429;
videoView.setVideoURI(Uri.parse(uri));
// Loop
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
// Play
videoView.start();
}
use of android.widget.VideoView in project Tapad by berict.
the class TutorialHelper method playMotionAnimation.
void playMotionAnimation(int btnId, int phId, int motionId, Activity activity) {
VideoView videoView;
View placeholder;
videoView = (VideoView) activity.findViewById(btnId);
placeholder = (View) activity.findViewById(phId);
animator(videoView, placeholder, motionId, activity);
Log.i("MotionAnimation", "Animation played on " + activity.getResources().getResourceEntryName(phId));
}
Aggregations