當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaProjectionManager.getMediaProjection方法代碼示例

本文整理匯總了Java中android.media.projection.MediaProjectionManager.getMediaProjection方法的典型用法代碼示例。如果您正苦於以下問題:Java MediaProjectionManager.getMediaProjection方法的具體用法?Java MediaProjectionManager.getMediaProjection怎麽用?Java MediaProjectionManager.getMediaProjection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.media.projection.MediaProjectionManager的用法示例。


在下文中一共展示了MediaProjectionManager.getMediaProjection方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onActivityResult

import android.media.projection.MediaProjectionManager; //導入方法依賴的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();
    }
}
 
開發者ID:monthlypub,項目名稱:SmingZZick_App,代碼行數:20,代碼來源:MainActivity.java

示例2: onActivityResult

import android.media.projection.MediaProjectionManager; //導入方法依賴的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);
        }
    }
}
 
開發者ID:farkam135,項目名稱:GoIV,代碼行數:24,代碼來源:MainActivity.java

示例3: onActivityResult

import android.media.projection.MediaProjectionManager; //導入方法依賴的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();
		}

	}
}
 
開發者ID:renard314,項目名稱:screenshare-playground,代碼行數:26,代碼來源:MainActivity.java

示例4: startRecording

import android.media.projection.MediaProjectionManager; //導入方法依賴的package包/類
private void startRecording() {
    //Initialize MediaRecorder class and initialize it with preferred configuration
    mMediaRecorder = new MediaRecorder();
    initRecorder();

    //Set Callback for MediaProjection
    mMediaProjectionCallback = new MediaProjectionCallback();
    MediaProjectionManager mProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);

    //Initialize MediaProjection using data received from Intent
    mMediaProjection = mProjectionManager.getMediaProjection(result, data);
    mMediaProjection.registerCallback(mMediaProjectionCallback, null);

    /* Create a new virtual display with the actual default display
             * and pass it on to MediaRecorder to start recording */
    mVirtualDisplay = createVirtualDisplay();
    try {
        mMediaRecorder.start();

        //If floating controls is enabled, start the floating control service and bind it here
        if (useFloatingControls) {
            Intent floatinControlsIntent = new Intent(this, FloatingControlService.class);
            startService(floatinControlsIntent);
            bindService(floatinControlsIntent,
                    serviceConnection, BIND_AUTO_CREATE);
        }

        //Set the state of the recording
        if (isBound)
            floatingControlService.setRecordingState(Const.RecordingState.RECORDING);
        isRecording = true;

        //Send a broadcast receiver to the plugin app to enable show touches since the recording is started
        if (showTouches) {
            Intent TouchIntent = new Intent();
            TouchIntent.setAction("com.orpheusdroid.screenrecorder.SHOWTOUCH");
            TouchIntent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
            sendBroadcast(TouchIntent);
        }
        Toast.makeText(this, R.string.screen_recording_started_toast, Toast.LENGTH_SHORT).show();
    } catch (IllegalStateException e) {
        Log.d(Const.TAG, "Mediarecorder reached Illegal state exception. Did you start the recording twice?");
        Toast.makeText(this, R.string.recording_failed_toast, Toast.LENGTH_SHORT).show();
        isRecording = false;
    }

            /* Add Pause action to Notification to pause screen recording if the user's android version
             * is >= Nougat(API 24) since pause() isnt available previous to API24 else build
             * Notification with only default stop() action */
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        //startTime is to calculate elapsed recording time to update notification during pause/resume
        startTime = System.currentTimeMillis();
        Intent recordPauseIntent = new Intent(this, RecorderService.class);
        recordPauseIntent.setAction(Const.SCREEN_RECORDING_PAUSE);
        PendingIntent precordPauseIntent = PendingIntent.getService(this, 0, recordPauseIntent, 0);
        NotificationCompat.Action action = new NotificationCompat.Action(android.R.drawable.ic_media_pause,
                getString(R.string.screen_recording_notification_action_pause), precordPauseIntent);

        //Start Notification as foreground
        startNotificationForeGround(createRecordingNotification(action).build(), Const.SCREEN_RECORDER_NOTIFICATION_ID);
    } else
        startNotificationForeGround(createRecordingNotification(null).build(), Const.SCREEN_RECORDER_NOTIFICATION_ID);
}
 
開發者ID:vijai1996,項目名稱:screenrecorder,代碼行數:64,代碼來源:RecorderService.java

示例5: getProjection

import android.media.projection.MediaProjectionManager; //導入方法依賴的package包/類
public MediaProjection getProjection(MediaProjectionManager manager) {
    return manager.getMediaProjection(resultCode, projectionIntent);
}
 
開發者ID:madisp,項目名稱:trails,代碼行數:4,代碼來源:RecordRequest.java

示例6: initVirtualDisplay

import android.media.projection.MediaProjectionManager; //導入方法依賴的package包/類
private void initVirtualDisplay(MediaProjectionManager manager, Intent data, int screenWidth, int screenHeight, int screenDensity) {
    mImageReader = ImageReader.newInstance(screenWidth, screenHeight, PixelFormat.RGBA_8888, 1);
    mMediaProjection = manager.getMediaProjection(Activity.RESULT_OK, data);
    mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
            screenWidth, screenHeight, screenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
            mImageReader.getSurface(), null, null);
}
 
開發者ID:feifadaima,項目名稱:https-github.com-hyb1996-NoRootScriptDroid,代碼行數:8,代碼來源:ScreenCapturer.java

示例7: initScreenManager

import android.media.projection.MediaProjectionManager; //導入方法依賴的package包/類
private void initScreenManager() {
    L.d("初始化錄屏。。。");

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        mMediaProjectionManager = (MediaProjectionManager)
                getSystemService(Context.MEDIA_PROJECTION_SERVICE);

        mMediaProjection = mMediaProjectionManager.getMediaProjection(Activity.RESULT_OK,
                mCapturePermissionIntent);
    }
    startDisplayManager();
    new Thread(new EncoderWorker()).start();
}
 
開發者ID:kaixuanluo,項目名稱:pc-android-controller-android,代碼行數:14,代碼來源:ScreenRecodeService.java

示例8: initVirtualDisplay

import android.media.projection.MediaProjectionManager; //導入方法依賴的package包/類
private void initVirtualDisplay(MediaProjectionManager manager, Intent data, int screenWidth, int screenHeight, int screenDensity) {
    mImageReader = ImageReader.newInstance(screenWidth, screenHeight, PixelFormat.RGBA_8888, 2);
    mMediaProjection = manager.getMediaProjection(Activity.RESULT_OK, data);
    mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
            screenWidth, screenHeight, screenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
            mImageReader.getSurface(), null, null);
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:8,代碼來源:ScreenCapturer.java

示例9: setProjectionData

import android.media.projection.MediaProjectionManager; //導入方法依賴的package包/類
public void setProjectionData(Intent data) {
    MediaProjectionManager mediaProjectionManager =
            (MediaProjectionManager) context.getSystemService(Context.MEDIA_PROJECTION_SERVICE);

    mediaProjection = mediaProjectionManager.getMediaProjection(Activity.RESULT_OK, data);
    if (mediaProjection != null) {
        //disable callback as it doesn't work anyways
        //mediaProjection.registerCallback(mediaProjectionCallback, handler);
        if (getState() == RecordingProcessState.STARTING) {
            start(file, null);
        } else {
            setState(RecordingProcessState.READY, null);
        }
    }
}
 
開發者ID:iwo,項目名稱:SCR-Screen-Recorder-app,代碼行數:16,代碼來源:ProjectionThreadRunner.java

示例10: onActivityResult

import android.media.projection.MediaProjectionManager; //導入方法依賴的package包/類
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.v(TAG,"onActivityResult");
    if(requestCode!=CAPTURE_CODE){
        Log.e(TAG,"onActivityResult : requestCode!=CAPTURE_CODE");
        return;
    }
    if (resultCode != RESULT_OK) {
        Log.e(TAG,"onActivityResult : resultCode != RESULT_OK");
        mMediaProjectionManager = (MediaProjectionManager) getSystemService(Context.MEDIA_PROJECTION_SERVICE);
        startActivityForResult(mMediaProjectionManager.createScreenCaptureIntent(), CAPTURE_CODE);
    }
    mMediaProjection = mMediaProjectionManager.getMediaProjection(resultCode,data);
    session.setMediaProjection(mMediaProjection);
    InitCameraView();
}
 
開發者ID:lijundacom,項目名稱:AndroidRTSPLib2,代碼行數:16,代碼來源:MainActivity.java


注:本文中的android.media.projection.MediaProjectionManager.getMediaProjection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。