本文整理匯總了Java中android.media.projection.MediaProjection類的典型用法代碼示例。如果您正苦於以下問題:Java MediaProjection類的具體用法?Java MediaProjection怎麽用?Java MediaProjection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MediaProjection類屬於android.media.projection包,在下文中一共展示了MediaProjection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onActivityResult
import android.media.projection.MediaProjection; //導入依賴的package包/類
@Override
@TargetApi(21)
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK) {
String uri = data.toUri(0);
MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(Activity.MEDIA_PROJECTION_SERVICE);
MediaProjection mediaProjection = projectionManager.getMediaProjection(resultCode, data);
ScreenCaptureService.setMediaProjection(mediaProjection);
startService(new Intent(ScreenCaptureService.ACTION_START, null, this, ScreenCaptureService.class));
fab.setSelected(true);
}
if (requestCode == REQUEST_CODE_MAKE_SMING && resultCode == RESULT_OK) {
loadSmings();
checkEmpty();
}
}
示例2: showYZBRecordDialog
import android.media.projection.MediaProjection; //導入依賴的package包/類
private void showYZBRecordDialog(MediaProjection mediaProjection, String path, boolean isRecordAudio) {
if (mYZBRecordScreenDialog == null) {
mYZBRecordScreenDialog = new YZBRecordScreenDialog(getContext(), R.style.record_dialog);
mYZBRecordScreenDialog.setFilePath(path);
Window window = mYZBRecordScreenDialog.getWindow();
window.setGravity(Gravity.BOTTOM);
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(layoutParams);
mYZBRecordScreenDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
// showSystemUI();
}
});
}
//第二個參數表述是否錄製音頻數據
mYZBRecordScreenDialog.setActivityResult(mediaProjection, isRecordAudio);
mYZBRecordScreenDialog.setIShareLivePlayer(mIShareLivePlayer);
mYZBRecordScreenDialog.setCallback(mCallback);
mYZBRecordScreenDialog.show();
}
示例3: showRecordDialog
import android.media.projection.MediaProjection; //導入依賴的package包/類
private void showRecordDialog(MediaProjection mediaProjection, String filePath, boolean isRecordAudio) {
if (mRecordDialog == null) {
mRecordDialog = new RecordScreenDialog(getContext(), R.style.record_dialog);
mRecordDialog.setFilePath(filePath);
Window window = mRecordDialog.getWindow();
window.setGravity(Gravity.BOTTOM);
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(layoutParams);
mRecordDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
// showSystemUI();
}
});
}
//第二個參數表述是否錄製音頻數據
mRecordDialog.setActivityResult(mediaProjection, isRecordAudio);
mRecordDialog.setIShareLivePlayer(mIShareLivePlayer);
mRecordDialog.setCallback(mCallback);
mRecordDialog.show();
}
示例4: initCapture
import android.media.projection.MediaProjection; //導入依賴的package包/類
public void initCapture(Context context, MediaProjection mediaProjection, final String path, final IRecordShotCallback callback){
int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
int screenHeight = context.getResources().getDisplayMetrics().heightPixels;
// thread for image checking
mCheckThread = new HandlerThread("CheckHandler");
mCheckThread.start();
mCheckHandler = new Handler(mCheckThread.getLooper());
try {
mImageReader = ImageReader.newInstance(screenWidth, screenHeight, PixelFormat.RGBA_8888, 2);
mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
imageAvailable(reader, path, callback);
}
}, mCheckHandler);
mSurface = mImageReader.getSurface();
}finally {
}
mVirtualDisplay = mediaProjection.createVirtualDisplay("mediaprojection", screenWidth, screenHeight,
1, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mSurface, null, null);
}
示例5: ProjectionManager
import android.media.projection.MediaProjection; //導入依賴的package包/類
public ProjectionManager(Context context, DisplayMetrics metrics,
int permissionsResultCode, Intent permissionsData, final MediaRouter router) {
mDensity = metrics.densityDpi;
mProjection = ((MediaProjectionManager) context.getSystemService(Context.MEDIA_PROJECTION_SERVICE))
.getMediaProjection(permissionsResultCode, permissionsData);
if (mProjection == null) {
throw new IllegalStateException("Null media projection manager - " + CastScreenActivity.PLEASE_REPORT_BUG);
}
// When the MediaProjection is stopped, deselect the active route to ensure casting stops
mProjection.registerCallback(new MediaProjection.Callback() {
@Override
public void onStop() {
router.selectRoute(router.getDefaultRoute());
}
}, null);
}
示例6: onActivityResult
import android.media.projection.MediaProjection; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.M)
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE_MEDIAPROJECTION) {
if (resultCode == RESULT_OK) {
MediaProjection projection = mProjectionManager.getMediaProjection(resultCode, data);
mScreenCapture = new ScreenCapture(this, projection);
}
} else {
if (!android.provider.Settings.canDrawOverlays(this)) {
Snackbar.make(contentView, getString(R.string.pleaseEnablePermissions), Snackbar.LENGTH_LONG).show();
} else {
tryToLaunchGame();
}
}
}
示例7: onActivityResult
import android.media.projection.MediaProjection; //導入依賴的package包/類
@TargetApi(Build.VERSION_CODES.M)
@Override
/**
* Called when another activity has sent a result to this activity. For example when this activity starts the
* activity which calls for the projectionmanager, which tells this class if the screen capture has been enabled.
*/
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
updateLaunchButtonText(false);
} else if (requestCode == SCREEN_CAPTURE_REQ_CODE) {
if (resultCode == RESULT_OK) {
MediaProjectionManager projectionManager = (MediaProjectionManager) getSystemService(
Context.MEDIA_PROJECTION_SERVICE);
MediaProjection mProjection = projectionManager.getMediaProjection(resultCode, data);
screen = ScreenGrabber.init(mProjection, rawDisplayMetrics);
startPokeFly();
} else {
updateLaunchButtonText(false);
}
}
}
示例8: Session
import android.media.projection.MediaProjection; //導入依賴的package包/類
public Session(int type,String mVideoPath,String mDestination,int mDestinationPort,
VideoQuality mVideoQuality,int mTimeToLive,
String mOrigin,int mOriginPort,MediaProjection mMediaProjection){
this.sessionType = type;
this.mVideoPath = mVideoPath;
this.mDestination = mDestination;
this.mDestinationPort = mDestinationPort;
this.mVideoQuality = mVideoQuality;
this.mTimeToLive = mTimeToLive;
this.mOrigin = mOrigin;
this.mOriginPort = mOriginPort;
this.mMediaProjection = mMediaProjection;
try {
mDestinationAddress = InetAddress.getByName(mDestination);
} catch (UnknownHostException e) {
e.printStackTrace();
}
long uptime = System.currentTimeMillis();
HandlerThread thread = new HandlerThread("com.example.ljd.mylibstreaming.LibRTSP.session.Session");
thread.start();
mHandler = new Handler(thread.getLooper());
mMainHandler = new Handler(Looper.getMainLooper());
mTimestamp = (uptime/1000)<<32 & (((uptime-((uptime/1000)*1000))>>32)/1000); // NTP timestamp
}
示例9: onActivityResult
import android.media.projection.MediaProjection; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
String ip = mReceiverIpEditText.getText().toString();
final SharedPreferences sharedPreferences = getSharedPreferences(PREF_NAME, 0);
final SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString(RECEIVER_IP_KEY,ip);
edit.commit();
if(resultCode == RESULT_OK && requestCode==GET_MEDIA_PROJECTION_CODE){
try {
@SuppressWarnings("ResourceType") MediaProjectionManager mediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);
final MediaProjection mediaProjection = mediaProjectionManager.getMediaProjection(resultCode, data);
mEncoderAsyncTask = new EncoderAsyncTask(this, mediaProjection, mMediaCodecFactory);
mEncoderAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
mSenderAsyncTask = new SenderAsyncTask(ip);
mSenderAsyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (IOException e) {
mStartButton.setEnabled(false);
mStartButton.setText(getString(R.string.mediacodec_error));
e.printStackTrace();
}
}
}
示例10: onActivityResult
import android.media.projection.MediaProjection; //導入依賴的package包/類
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_CODE) {
if (resultCode != RESULT_OK) {
return;
}
MediaProjection mediaProjection = mMediaProjectionManager.getMediaProjection(resultCode, data);
mScreenRecorder = new EasyScreenRecorder(this, generatePath(getDateTimeString()), mediaProjection);
mScreenRecorder.start();
}
}
示例11: MediaScreenEncoder
import android.media.projection.MediaProjection; //導入依賴的package包/類
public MediaScreenEncoder(final MediaMuxerWrapper muxer, final MediaEncoderListener listener,
final MediaProjection projection, final int width, final int height, final int density,
final int _bitrate, final int _fps) {
super(muxer, listener, width, height);
mMediaProjection = projection;
mDensity = density;
fps = (_fps > 0 && _fps <= 30) ? _fps : FRAME_RATE;
bitrate = (_bitrate > 0) ? _bitrate : calcBitRate(_fps);
final HandlerThread thread = new HandlerThread(TAG);
thread.start();
mHandler = new Handler(thread.getLooper());
}
示例12: createScreenCapturer
import android.media.projection.MediaProjection; //導入依賴的package包/類
@TargetApi(21)
private VideoCapturer createScreenCapturer() {
if (mediaProjectionPermissionResultCode != Activity.RESULT_OK) {
reportError("User didn't give permission to capture the screen.");
return null;
}
return new ScreenCapturerAndroid(
mediaProjectionPermissionResultData, new MediaProjection.Callback() {
@Override
public void onStop() {
reportError("User revoked permission to capture the screen.");
}
});
}
示例13: setActivityResult
import android.media.projection.MediaProjection; //導入依賴的package包/類
/**
* 設置開始後的ActivityResult回掉
*/
public void setActivityResult(int resultCode, Intent data, String filePath) {
if (mMediaProjectionManager == null) {
return;
}
MediaProjection mediaProjection = mMediaProjectionManager.getMediaProjection(resultCode, data);
TotalController.getInstance().captureScreenImage(getContext(), mFilePath, mediaProjection, mCallback);
}
示例14: start
import android.media.projection.MediaProjection; //導入依賴的package包/類
/**
* onActivityResult(XXXX)回掉之後就該調用這個方法
*
* @param context
* @param mediaProjection
* @param isAudience
*/
public void start(Context context, MediaProjection mediaProjection, Boolean isAudience) {
if (mYixiaMuxerWrapper != null) {
mYixiaMuxerWrapper.setIsRecordAudio(isAudience);
}
isRecording = true;
mVideoHandlerThread.prepar(context, mediaProjection, mYixiaMuxerWrapper);
mVideoHandlerThread.startRecording();
mAudioHandlerThread.prepar(mYixiaMuxerWrapper);
mAudioHandlerThread.startRecording();
}
示例15: createScreenCapturer
import android.media.projection.MediaProjection; //導入依賴的package包/類
@TargetApi(21)
private VideoCapturer createScreenCapturer() {
if (mediaProjectionPermissionResultCode != Activity.RESULT_OK) {
reportError("User didn't give permission to capture the screen.");
return null;
}
return new ScreenCapturerAndroid(
mediaProjectionPermissionResultData, new MediaProjection.Callback() {
@Override
public void onStop() {
reportError("User revoked permission to capture the screen.");
}
});
}