Java Code Examples for android.view.SurfaceHolder#setType()

The following examples show how to use android.view.SurfaceHolder#setType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CaptureActivity.java    From MaterialHome with Apache License 2.0 6 votes vote down vote up
@Override
    protected void onResume() {
        super.onResume();
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        if (hasSurface) {
            initCamera(surfaceHolder);
        } else {
            surfaceHolder.addCallback(this);
            surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        }
        decodeFormats = null;
        characterSet = null;

        playBeep = true;
        AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
        if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
            playBeep = false;
        }
        initBeepSound();
        vibrate = true;
//        MobclickAgent.onResume(this);
    }
 
Example 2
Source File: CaptureActivity.java    From lunzi with Apache License 2.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        initCamera(surfaceHolder);
    } else {
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
    decodeFormats = null;
    characterSet = null;

    playBeep = true;
    AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
    if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
        playBeep = false;
    }
    initBeepSound();
    vibrate = true;
}
 
Example 3
Source File: CaptureActivity.java    From QrCodeLib with MIT License 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.scanner_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        initCamera(surfaceHolder);
    } else {
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
    decodeFormats = null;
    characterSet = null;

    playBeep = true;
    AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
    if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
        playBeep = false;
    }
    initBeepSound();
    vibrate = true;

}
 
Example 4
Source File: MediaShootActivity.java    From BigApp_WordPress_Android with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
	getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
			WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
	super.onCreate(savedInstanceState);
	setContentView(R.layout.zg_activity_video_shoot);
	mFacing = (TextView) findViewById(R.id.tv_facing);
	mSurfaceView = (SurfaceView) findViewById(R.id.surfaceview_shoot);
	mShoot = (ImageView) findViewById(R.id.img_shoot);
	mChronometer = (Chronometer) findViewById(R.id.video_chronometer);
	mFacing.setOnClickListener(this);
	mShoot.setOnClickListener(this);

	initToggle();
	findViewById(R.id.iv_left).setOnClickListener(this);

	SurfaceHolder mHolder = mSurfaceView.getHolder();
	mHolder.addCallback(this);
	mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
 
Example 5
Source File: CaptureActivity.java    From DoraemonKit with Apache License 2.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    SurfaceView surfaceView = findViewById(R.id.scanner_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        initCamera(surfaceHolder);
    } else {
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
    decodeFormats = null;
    characterSet = null;

    vibrate = true;
}
 
Example 6
Source File: CaptureActivity.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        initCamera(surfaceHolder);
    } else {
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
    decodeFormats = null;
    characterSet = null;

    playBeep = true;
    AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
    if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
        playBeep = false;
    }
    initBeepSound();
    vibrate = true;

}
 
Example 7
Source File: QrViewActivity.java    From LLApp with Apache License 2.0 6 votes vote down vote up
@Override
protected void onInitView() {
    setTitle("扫描界面");
    toolbar.setNavigationIcon(R.mipmap.abc_ic_ab_back_mtrl_am_alpha);
    toolbar.setNavigationOnClickListener(v -> finish());

    hasSurface = false;

    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    surfaceHolder.addCallback(this);
    surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    inactivityTimer = new InactivityTimer(this);
    flag = getIntent().getIntExtra("flag",0);//flag==1说明是从notoy界面进入的

    requestPermission(new String[]{Manifest.permission.CAMERA}, "请求设备权限", new GrantedResult() {
        @Override
        public void onResult(boolean granted) {
            if (granted) {
                initCamera();
            } else {
                finish();
            }
        }
    });
}
 
Example 8
Source File: CaptureVideoActivity.java    From NIM_Android_UIKit with MIT License 6 votes vote down vote up
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().setFormat(PixelFormat.TRANSLUCENT); // 使得窗口支持透明度
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.nim_capture_video_activity);
    setTitle(R.string.video_record);
    parseIntent();
    findViews();
    initActionBar();
    setViewsListener();
    updateRecordUI();
    getVideoPreviewSize();
    surfaceview = this.findViewById(R.id.videoView);
    SurfaceHolder holder = surfaceview.getHolder();
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder.addCallback(this);
    resizeSurfaceView();
}
 
Example 9
Source File: MediaRecorderBase.java    From VideoRecord with MIT License 5 votes vote down vote up
/**
 * 设置预览输出SurfaceHolder
 * @param sh
 */
@SuppressWarnings("deprecation")
public void setSurfaceHolder(SurfaceHolder sh) {
	if (sh != null) {
		sh.addCallback(this);
		if (!DeviceUtils.hasHoneycomb()) {
			sh.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
		}
	}
}
 
Example 10
Source File: CaptureActivity.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
@Override
protected void onResume()
{
    super.onResume();
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface)
    {
        initCamera(surfaceHolder);
    }
    else
    {
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
    decodeFormats = null;
    characterSet = null;

    playBeep = true;
    AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
    if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL)
    {
        playBeep = false;
    }
    initBeepSound();
    vibrate = true;
}
 
Example 11
Source File: TakeVideoActivity.java    From MultiMediaSample with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    //全屏
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);   //应用运行时,保持屏幕高亮,不锁屏
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_take_video);

    //获取控件
    surfaceView = (SurfaceView) findViewById(R.id.surfaceview);
    recordButton = (Button) findViewById(R.id.btn_start_record);
    unRecordButton = (Button) findViewById(R.id.btn_stop_record);
    previewButton = (Button) findViewById(R.id.btn_preview);
    recordButton.setOnClickListener(this);
    unRecordButton.setOnClickListener(this);
    previewButton.setOnClickListener(this);

    timeSecondView = (TextView) findViewById(R.id.time);
    curTimeView = (TextView) findViewById(R.id.tv_time);
    progressBar = (ProgressBar) findViewById(R.id.progressBar);
    progressBar.setMax(MaxDuring);

    SurfaceHolder holder = surfaceView.getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    startTime();

    //获取支持480p视频
    initSupportProfile();
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    //保持预览和视频长宽比一致,不拉伸压缩失真
    surfaceView.setLayoutParams(new FrameLayout.LayoutParams(-1, mVideoHeiht * dm.widthPixels / mVideoWidth, Gravity.TOP));

    fileCachePath = getIntent().getStringExtra("fileCachePath");
}
 
Example 12
Source File: LocalPlayer.java    From V.FlyoutTest with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    // Be sure to call the super class.
    super.onCreate(savedInstanceState);

    // Inflate the layout.
    setContentView(R.layout.sample_media_router_presentation);

    // Set up the surface view.
    mPresentationSurfaceView = (SurfaceView)findViewById(R.id.surface_view);
    SurfaceHolder holder = mPresentationSurfaceView.getHolder();
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder.addCallback(SurfaceViewPlayer.this);
    Log.i(TAG, "Presentation created");
}
 
Example 13
Source File: VideoViewRecycler.java    From MaterialDesignSupport with MIT License 5 votes vote down vote up
@SuppressWarnings("deprecation")
public VideoViewRecycler(Context context, AttributeSet attrs) {
    super(context, attrs);

    SurfaceHolder holder = getHolder();
    holder.addCallback(this);
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);

    mContext = context;
}
 
Example 14
Source File: LivePusher.java    From LivePublisher with MIT License 5 votes vote down vote up
public void prepare(SurfaceHolder surfaceHolder) {
	surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
	videoPusher = new VideoPusher(mActivity, surfaceHolder, videoParam,
			mNative);
	audioPusher = new AudioPusher(audioParam, mNative);
	videoPusher.setLiveStateChangeListener(mListener);
	audioPusher.setLiveStateChangeListener(mListener);
}
 
Example 15
Source File: DecoderActivity.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
    super.onResume();
    Log.v(TAG, "onResume()");

    // CameraManager must be initialized here, not in onCreate().
    if (cameraManager == null) cameraManager = new CameraManager(getApplication());

    if (viewfinderView == null) {
        viewfinderView = (ViewfinderView) findViewById(R.id.viewfinder_view);
        viewfinderView.setCameraManager(cameraManager);
    }

    showScanner();

    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    if (hasSurface) {
        // The activity was paused but not stopped, so the surface still
        // exists. Therefore
        // surfaceCreated() won't be called, so init the camera here.
        initCamera(surfaceHolder);
    } else {
        // Install the callback and wait for surfaceCreated() to init the
        // camera.
        surfaceHolder.addCallback(this);
        surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    }
}
 
Example 16
Source File: CaptureNewActivity.java    From KSYMediaPlayer_Android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onResume() {
	super.onResume();
	SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
	SurfaceHolder surfaceHolder = surfaceView.getHolder();
	if (hasSurface) {
		initCamera(surfaceHolder);
	} else {
		surfaceHolder.addCallback(this);
		surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
	}
	decodeFormats = null;
	characterSet = null;

	playBeep = true;
	AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
	if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
		playBeep = false;
	}
	initBeepSound();
	vibrate = true;
	
	//quit the scan view
	cancelScanButton.setOnClickListener(new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			CaptureNewActivity.this.finish();
		}
	});
}
 
Example 17
Source File: CaptureActivity.java    From QrCodeDemo4 with MIT License 5 votes vote down vote up
@Override
    protected void onResume() {
        super.onResume();
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.scanner_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        if (hasSurface) {
            initCamera(surfaceHolder);
        } else {
            surfaceHolder.addCallback(this);
            surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        }
        decodeFormats = null;
        characterSet = null;

        playBeep = true;
        AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
        if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
            playBeep = false;
        }
        initBeepSound();
        vibrate = true;

        //quit the scan view
//		cancelScanButton.setOnClickListener(new OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//				CaptureActivity.this.finish();
//			}
//		});
    }
 
Example 18
Source File: CaptureActivity.java    From vmqApk with MIT License 5 votes vote down vote up
@Override
    protected void onResume() {
        super.onResume();
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.scanner_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        if (hasSurface) {
            initCamera(surfaceHolder);
        } else {
            surfaceHolder.addCallback(this);
            surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
        }
        decodeFormats = null;
        characterSet = null;

        playBeep = true;
        AudioManager audioService = (AudioManager) getSystemService(AUDIO_SERVICE);
        if (audioService.getRingerMode() != AudioManager.RINGER_MODE_NORMAL) {
            playBeep = false;
        }
        initBeepSound();
        vibrate = true;

        //quit the scan view
//		cancelScanButton.setOnClickListener(new OnClickListener() {
//
//			@Override
//			public void onClick(View v) {
//				CaptureActivity.this.finish();
//			}
//		});
    }
 
Example 19
Source File: LocalPlayer.java    From media-samples with Apache License 2.0 5 votes vote down vote up
public SurfaceViewPlayer(Context context) {
    super(context);

    mLayout = (FrameLayout)((Activity)context).findViewById(R.id.player);
    mSurfaceView = (SurfaceView)((Activity)context).findViewById(R.id.surface_view);

    // add surface holder callback
    SurfaceHolder holder = mSurfaceView.getHolder();
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder.addCallback(this);
}
 
Example 20
Source File: CapturePreview.java    From LandscapeVideoCamera with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private void initalizeSurfaceHolder(final SurfaceHolder surfaceHolder) {
	surfaceHolder.removeCallback(this);
	surfaceHolder.addCallback(this);
	surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Necessary for older API's
}