Java 类android.view.SurfaceView 实例源码

项目:GitHub    文件:TvShowActivity.java   
private void initPlayer() {
    mLoadingView = findViewById(R.id.LoadingView);
    bgImage = (ImageView) findViewById(R.id.bgImg);
    mSurfaceView = (SurfaceView) findViewById(R.id.surfaceView);
    mSurfaceView.setOnTouchListener(this);
    try {
        mPlayBean = (FirstBean.RoomBean.ListBean) getIntent().getSerializableExtra("playBean");
    } catch (ClassCastException e) {
        mPlayBean1 = (OtherBean.DataBean) getIntent().getSerializableExtra("playBean");
    }

    mCodec = getIntent().getIntExtra("mediaCodec", 0);
}
项目:GitHub    文件:LivePlayerHolder.java   
public LivePlayerHolder(BaseTvShowActivity mActivity, SurfaceView surfaceView, Integer codec, String mVideoPath) {
    this.mActivity = mActivity;
    this.codec = codec;
    this.mVideoPath = mVideoPath;
    this.mSurfaceView = surfaceView;
    //init
    mSurfaceView.getHolder().addCallback(mCallback);
    mAVOptions = new AVOptions();
    mAVOptions.setInteger(AVOptions.KEY_PREPARE_TIMEOUT, 10 * 1000);
    mAVOptions.setInteger(AVOptions.KEY_GET_AV_FRAME_TIMEOUT, 10 * 1000);
    mAVOptions.setInteger(AVOptions.KEY_LIVE_STREAMING, 1);
    mAVOptions.setInteger(AVOptions.KEY_DELAY_OPTIMIZATION, 1);
    mAVOptions.setInteger(AVOptions.KEY_MEDIACODEC, codec);

    // whether start play automatically after prepared, default value is 1
    mAVOptions.setInteger(AVOptions.KEY_START_ON_PREPARED, 0);
    AudioManager audioManager = (AudioManager) App.getAppContext().getSystemService(Context.AUDIO_SERVICE);
    audioManager.requestAudioFocus(null, AudioManager.STREAM_MUSIC, AudioManager.AUDIOFOCUS_GAIN);
}
项目:FaceRecognition    文件:MainActivity.java   
private void initView(){

        face1Result = (ImageView) findViewById(R.id.face1);
        btnToggleCamera = (ImageButton) findViewById(R.id.btnToggleCamera);
        btnGetFace = (ImageButton) findViewById(R.id.btnGetFace);
        btnGetInto = (Button) findViewById(R.id.btnGetInto);
        btnSignup =(Button) findViewById(R.id.btnsignup);
        surfaceView =  (SurfaceView) findViewById(R.id.surfaceView);
        surfaceHolder = surfaceView.getHolder();
        mGlobal = (Global) getApplicationContext();
        mInterface = new CameraInterface(MainActivity.this);
        executor = Executors.newSingleThreadExecutor();
        loader = Global.loader;
        faceView = (FaceView) findViewById(R.id.face_view);
        faceView = (FaceView) findViewById(R.id.face_view);

    }
项目:decoy    文件:CaptureVideoActivity.java   
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 = (SurfaceView) this.findViewById(R.id.videoView);
    SurfaceHolder holder = surfaceview.getHolder();
    holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    holder.addCallback(this);

    resizeSurfaceView();
}
项目:keepass2android    文件:CaptureActivity.java   
@Override
protected void onPause() {
  if (handler != null) {
    handler.quitSynchronously();
    handler = null;
  }
  inactivityTimer.onPause();
  ambientLightManager.stop();
  cameraManager.closeDriver();
  if (!hasSurface) {
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
    SurfaceHolder surfaceHolder = surfaceView.getHolder();
    surfaceHolder.removeCallback(this);
  }
  super.onPause();
}
项目:live_master    文件:PushLiveActivity.java   
private void initViews() {
    btnPublish = (ImageButton) findViewById(R.id.publish);
    btnSwitch = (ImageButton) findViewById(R.id.swCam);
    btnBack = (ImageButton) findViewById(R.id.back);
    txtState = (TextView) findViewById(R.id.state);
    mCameraView = (SurfaceView) findViewById(R.id.preview);
    mMessagesView = (RecyclerView) findViewById(R.id.push_messages_receive_layout);
    linearLayoutManager = new LinearLayoutManager(this);
    linearLayoutManager.setStackFromEnd(true);
    mMessagesView.setLayoutManager(linearLayoutManager);
    mMessagesView.setAdapter(mAdapter);
    mCameraView.getHolder().addCallback(this);
    btnPublish.setOnClickListener(this);
    btnSwitch.setOnClickListener(this);
    btnBack.setOnClickListener(this);
}
项目:SWDemo    文件:SmallVideoViewLiveAdapter.java   
@Override
public void notifyUiChanged(HashMap<Integer, SurfaceView> uids, int uidExcluded, HashMap<Integer, Integer> status, HashMap<Integer, Integer> volume) {
    mUsers.clear();

    for (HashMap.Entry<Integer, SurfaceView> entry : uids.entrySet()) {
        log.debug("notifyUiChanged " + entry.getKey() + " " + uidExcluded);

        if (entry.getKey() != uidExcluded) {
            entry.getValue().setZOrderOnTop(true);
            entry.getValue().setZOrderMediaOverlay(true);
            mUsers.add(new VideoStatusData(entry.getKey(), entry.getValue(), VideoStatusData.DEFAULT_STATUS, VideoStatusData.DEFAULT_VOLUME));
        }
    }

    notifyDataSetChanged();
}
项目:Phoenix-for-VK    文件:GifPagerFragment.java   
Holder(int adapterPosition, View rootView) {
    super(adapterPosition, rootView);
    FlingRelativeLayout flingRelativeLayout = (FlingRelativeLayout) rootView.findViewById(R.id.fling_root_view);
    flingRelativeLayout.setOnClickListener(v -> toggleFullscreen());
    flingRelativeLayout.setOnSingleFlingListener(new CloseOnFlingListener(rootView.getContext()) {
        @Override
        public boolean onVerticalFling(float distanceByY) {
            goBack();
            return true;
        }
    });

    mSurfaceView = (SurfaceView) rootView.findViewById(R.id.surface_view);
    mSurfaceHolder = mSurfaceView.getHolder();
    mSurfaceHolder.addCallback(this);

    mAspectRatioLayout = (AlternativeAspectRatioFrameLayout) rootView.findViewById(R.id.aspect_ratio_layout);
    mProgressBar = (ProgressBar) rootView.findViewById(R.id.preparing_progress_bar);
}
项目:LuaViewPlayground    文件:CaptureActivity.java   
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_capture);

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);

    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
            .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);
}
项目:xwallet    文件:SendFragmentView.java   
/**
 *
 */
@Override
public void initViews() {
    View fragView = _sendFragment.getView();
    if (fragView == null) return;

    _amountEdit = (EditText) fragView.findViewById(R.id.send_amount_textview);
    _addressEdit = (EditText) fragView.findViewById(R.id.send_address_input);
    _maxTextView = (TextView) fragView.findViewById(R.id.send_max_textview);
    _sendBtn = (CircleImageView) fragView.findViewById(R.id.send_btn_id);
    _surfaceView = (SurfaceView) fragView.findViewById(R.id.send_camera_preview);

    _maxTextView.setOnClickListener(this);
    _sendBtn.setOnClickListener(this);
    _addressEdit.addTextChangedListener(this);
    _amountEdit.addTextChangedListener(this);

    System.out.println("listeners setup");
}
项目:grafika    文件:PlayMovieSurfaceActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_play_movie_surface);

    mSurfaceView = (SurfaceView) findViewById(R.id.playMovie_surface);
    mSurfaceView.getHolder().addCallback(this);

    // Populate file-selection spinner.
    Spinner spinner = (Spinner) findViewById(R.id.playMovieFile_spinner);
    // Need to create one of these fancy ArrayAdapter thingies, and specify the generic layout
    // for the widget itself.
    mMovieFiles = MiscUtils.getFiles(getFilesDir(), "*.mp4");
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
            android.R.layout.simple_spinner_item, mMovieFiles);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner.
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(this);

    updateControls();
}
项目:tvConnect_android    文件:CaptureActivity.java   
@Override
protected void onPause() {
    if (handler != null) {
        handler.quitSynchronously();
        handler = null;
    }
    inactivityTimer.onPause();
    ambientLightManager.stop();
    beepManager.close();
    cameraManager.closeDriver();
    if (!hasSurface) {
        SurfaceView surfaceView = (SurfaceView) findViewById(R.id.preview_view);
        SurfaceHolder surfaceHolder = surfaceView.getHolder();
        surfaceHolder.removeCallback(this);
    }
    super.onPause();
}
项目:OpenLive-Android    文件:LiveRoomActivity.java   
@Override
public void onJoinChannelSuccess(final String channel, final int uid, final int elapsed) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            if (isFinishing()) {
                return;
            }

            if (mUidsList.containsKey(uid)) {
                log.debug("already added to UI, ignore it " + (uid & 0xFFFFFFFFL) + " " + mUidsList.get(uid));
                return;
            }

            final boolean isBroadcaster = isBroadcaster();
            log.debug("onJoinChannelSuccess " + channel + " " + uid + " " + elapsed + " " + isBroadcaster);

            worker().getEngineConfig().mUid = uid;

            SurfaceView surfaceV = mUidsList.remove(0);
            if (surfaceV != null) {
                mUidsList.put(uid, surfaceV);
            }
        }
    });
}
项目:SWDemo    文件:GridVideoViewContainer.java   
public void initViewContainer(Context context, int localUid, HashMap<Integer, SurfaceView> uids) {
    boolean newCreated = initAdapter(localUid, uids);

    if (!newCreated) {
        mGridVideoViewContainerAdapter.setLocalUid(localUid);
        mGridVideoViewContainerAdapter.customizedInit(uids, true);
    }

    this.setAdapter(mGridVideoViewContainerAdapter);

    int count = uids.size();
    if (count <= 2) { // only local full view or or with one peer
        this.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
    } else if (count > 2 && count <= 4) {
        this.setLayoutManager(new GridLayoutManager(context, 2, RecyclerView.VERTICAL, false));
    }

    mGridVideoViewContainerAdapter.notifyDataSetChanged();
}
项目:zxing_qrcode_demo    文件:CaptureFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

    Bundle bundle = getArguments();
    View view = null;
    if (bundle != null) {
        int layoutId = bundle.getInt(CodeUtils.LAYOUT_ID);
        if (layoutId != -1) {
            view = inflater.inflate(layoutId, null);
        }
    }

    if (view == null) {
        view = inflater.inflate(R.layout.fragment_capture_view, null);
    }

    viewfinderView = (ViewfinderView) view.findViewById(R.id.viewfinder_view);
    surfaceView = (SurfaceView) view.findViewById(R.id.preview_view);
    surfaceHolder = surfaceView.getHolder();

    return view;
}
项目:grafika    文件:MultiSurfaceActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_multi_surface_test);

    // #1 is at the bottom; mark it as secure just for fun.  By default, this will use
    // the RGB565 color format.
    mSurfaceView1 = (SurfaceView) findViewById(R.id.multiSurfaceView1);
    mSurfaceView1.getHolder().addCallback(this);
    mSurfaceView1.setSecure(true);

    // #2 is above it, in the "media overlay"; must be translucent or we will totally
    // obscure #1 and it will be ignored by the compositor.  The addition of the alpha
    // plane should switch us to RGBA8888.
    mSurfaceView2 = (SurfaceView) findViewById(R.id.multiSurfaceView2);
    mSurfaceView2.getHolder().addCallback(this);
    mSurfaceView2.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    mSurfaceView2.setZOrderMediaOverlay(true);

    // #3 is above everything, including the UI.  Also translucent.
    mSurfaceView3 = (SurfaceView) findViewById(R.id.multiSurfaceView3);
    mSurfaceView3.getHolder().addCallback(this);
    mSurfaceView3.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    mSurfaceView3.setZOrderOnTop(true);
}
项目:OpenLive-Android    文件:GridVideoViewContainer.java   
public void initViewContainer(Context context, int localUid, HashMap<Integer, SurfaceView> uids) {
    boolean newCreated = initAdapter(localUid, uids);

    if (!newCreated) {
        mGridVideoViewContainerAdapter.setLocalUid(localUid);
        mGridVideoViewContainerAdapter.init(uids, localUid, true);
    }

    this.setAdapter(mGridVideoViewContainerAdapter);

    int count = uids.size();
    if (count <= 2) { // only local full view or or with one peer
        this.setLayoutManager(new LinearLayoutManager(context, RecyclerView.VERTICAL, false));
    } else if (count > 2 && count <= 4) {
        this.setLayoutManager(new GridLayoutManager(context, 2, RecyclerView.VERTICAL, false));
    }

    mGridVideoViewContainerAdapter.notifyDataSetChanged();
}
项目:grafika    文件:ScheduledSwapActivity.java   
@Override
public void surfaceCreated(SurfaceHolder holder) {
    Log.d(TAG, "surfaceCreated holder=" + holder);
    // If we already have a Surface, we just need to resume the frame notifications.

    SurfaceView sv = (SurfaceView) findViewById(R.id.scheduledSwap_surfaceView);
    mRenderThread = new RenderThread(sv.getHolder(), this);
    mRenderThread.setName("ScheduledSwap GL render");
    mRenderThread.start();
    mRenderThread.waitUntilReady();

    RenderHandler rh = mRenderThread.getHandler();
    if (rh != null) {
        rh.sendSetParameters(mUpdatePatternIndex, mFramesAheadIndex);
        rh.sendSurfaceCreated();
    }

    // start the draw events
    Choreographer.getInstance().postFrameCallback(this);
}
项目:ExVidPlayer    文件:ExVpCompleteFragment.java   
private void initViews() {
  progressBar = (ProgressBar) mView.findViewById(R.id.pbar);
  surfaceView = (SurfaceView) mView.findViewById(R.id.surface_view);
  //controls
  root = (LinearLayout) mView.findViewById(R.id.root);
  ivLock = (ImageButton) mView.findViewById(R.id.btn_lock);
  ivRev = (ImageButton) mView.findViewById(R.id.btn_rev);
  ivForword = (ImageButton) mView.findViewById(R.id.btn_fwd);
  ivNext = (ImageButton) mView.findViewById(R.id.btn_next);
  ivPrev = (ImageButton) mView.findViewById(R.id.btn_prev);
  ivPlayPause = (ImageButton) mView.findViewById(R.id.btn_pause);
  ivSetting = (ImageButton) mView.findViewById(R.id.btn_settings);
  mProgress = (SeekBar) mView.findViewById(R.id.seekbar);
  tvCurrent = (TextView) mView.findViewById(R.id.txt_currentTime);
  tvTotal = (TextView) mView.findViewById(R.id.txt_totalDuration);
  prgCenterText = (LinearLayout) mView.findViewById(R.id.seekbar_center_text);
  tvCenterCurrent = (TextView) mView.findViewById(R.id.txt_seek_currTime);
  tvCenterProg = (TextView) mView.findViewById(R.id.txt_seek_secs);
  //brightness
  brightnessSlider = (LinearLayout) getView(R.id.brightness_slider_container);
  ivBrightness = (ImageView) getView(R.id.brightness_image);
  ivBrightnessImage = (ImageView) getView(R.id.brightnessIcon);
  pBarBrighness = (ProgressBar) getView(R.id.brightness_slider);
  tvBrightnessPercent = (TextView) getView(R.id.brigtness_perc_center_text);
  brightnessCenterText = (LinearLayout) getView(R.id.brightness_center_text);
  //volume
  volumeSlider = (LinearLayout) getView(R.id.volume_slider_container);
  ivVolume = (ImageView) getView(R.id.vol_image);
  ivVolumeImage = (ImageView) getView(R.id.volIcon);
  pBarVolume = (VolBar) getView(R.id.volume_slider);
  tvVolumePercent = (TextView) getView(R.id.vol_perc_center_text);
  volumeCenterText = (LinearLayout) getView(R.id.vol_center_text);

  aspectRatioFrameLayout=(AspectRatioFrameLayout)getView(R.id.video_frame);
}
项目:SocialPaka    文件:CameraSourcePreview.java   
public CameraSourcePreview(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;
    mStartRequested = false;
    mSurfaceAvailable = false;

    mSurfaceView = new SurfaceView(context);
    mSurfaceView.getHolder().addCallback(new SurfaceCallback());
    addView(mSurfaceView);
}
项目:yjPlay    文件:SimpleExoPlayerView.java   
/**
 * Set the {@link SimpleExoPlayer} to use.
 * <p>
 * To transition a {@link SimpleExoPlayer} from targeting one view to another, it's recommended to
 * use {@link #switchTargetView(SimpleExoPlayer, SimpleExoPlayerView, SimpleExoPlayerView)} rather
 * than this method. If you do wish to use this method directly, be sure to attach the player to
 * the new view <em>before</em> calling {@code setPlayer(null)} to detach it from the old one.
 * This ordering is significantly more efficient and may allow for more seamless transitions.
 *
 * @param player The {@link SimpleExoPlayer} to use.
 */
public void setPlayer(SimpleExoPlayer player) {
    if (this.player == player) {
        return;
    }
    if (this.player != null) {
        this.player.removeListener(componentListener);
        this.player.removeTextOutput(componentListener);
        this.player.removeVideoListener(componentListener);
        if (surfaceView instanceof TextureView) {
            this.player.clearVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
        }
    }
    this.player = player;
    if (useController) {
        controller.setPlayer(player);
    }
    if (shutterView != null) {
        shutterView.setVisibility(VISIBLE);
    }
    if (player != null) {
        if (surfaceView instanceof TextureView) {
            player.setVideoTextureView((TextureView) surfaceView);
        } else if (surfaceView instanceof SurfaceView) {
            player.setVideoSurfaceView((SurfaceView) surfaceView);
        }
        player.addVideoListener(componentListener);
        player.addTextOutput(componentListener);
        player.addListener(componentListener);
        maybeShowController(false);
        updateForCurrentTrackSelections();
    } else {
        hideController();
        hideArtwork();
    }
}
项目:yjPlay    文件:SimpleExoPlayerView.java   
@Override
public void setVisibility(int visibility) {
    super.setVisibility(visibility);
    if (surfaceView instanceof SurfaceView) {
        // Work around https://github.com/google/ExoPlayer/issues/3160.
        surfaceView.setVisibility(visibility);
    }
}
项目:Barcode-Reader    文件:CameraSourcePreview.java   
public CameraSourcePreview(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;
    mStartRequested = false;
    mSurfaceAvailable = false;

    mSurfaceView = new SurfaceView(context);
    mSurfaceView.getHolder().addCallback(new SurfaceCallback());
    addView(mSurfaceView);
}
项目:GitHub    文件:ScanActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.scan_activity);
    init(this, (SurfaceView) findViewById(R.id.svCameraScan), (ViewfinderView) findViewById(R.id.vfvCameraScan));

    //功能归类分区方法,必须调用<<<<<<<<<<
    initView();
    initData();
    initEvent();
    //功能归类分区方法,必须调用>>>>>>>>>>

}
项目:FaceRecognition    文件:Main3Activity.java   
private void initView(){
    face1Result = (ImageView) findViewById(R.id.face1);
    btnToggleCamera = (ImageButton) findViewById(R.id.btnToggleCamera);
    btnSignup = (ImageButton) findViewById(R.id.btnGetFace);
    btnDelete = (Button) findViewById(R.id.btndelete);
    surfaceView =  (SurfaceView) findViewById(R.id.surfaceView);
    faceView = (FaceView) findViewById(R.id.face_view) ;

    surfaceHolder = surfaceView.getHolder();
    mGlobal = ((Global) getApplicationContext());
    mInterface = new CameraInterface(Main3Activity.this);
    executor = Executors.newSingleThreadExecutor();
    loader = Global.loader;
}
项目:Fuse    文件:CameraSource.java   
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The preview
 * frames are not displayed.
 *
 * @throws IOException if the camera's preview texture or display could not be initialized
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start() throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();

        // SurfaceTexture was introduced in Honeycomb (11), so if we are running and
        // old version of Android. fall back to use SurfaceView.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME);
            mCamera.setPreviewTexture(mDummySurfaceTexture);
        } else {
            mDummySurfaceView = new SurfaceView(mContext);
            mCamera.setPreviewDisplay(mDummySurfaceView.getHolder());
        }
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
项目:africastalking-android    文件:PjCamera.java   
public PjCamera(int idx, int w, int h, int fmt, int fps,
            long userData_, SurfaceView surface)
   {
camIdx = idx;
userData = userData_;

param = new Param();
param.width = w;
param.height = h;
param.format = fmt;
param.fps1000 = fps;

SetSurfaceView(surface);
   }
项目:OSchina_resources_android    文件:CaptureActivity.java   
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_qr_scan);

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    // Install the callback and wait for surfaceCreated() to init the
    // camera.
    scanPreview.getHolder().addCallback(this);

    cameraTask();
}
项目:ExVidPlayer    文件:ExVidPlayerImp.java   
public ExVidPlayerImp(Activity activity, SurfaceView surface, Handler handler,
    AspectRatioFrameLayout aspectRatioFrameLayout) {
  this.activity = activity;
  this.surface = surface;
  this.aspectRatioFrameLayout = aspectRatioFrameLayout;
  this.mainHandler = handler;
}
项目:BuddyBook    文件:CameraSource.java   
/**
 * Opens the camera and starts sending preview frames to the underlying detector.  The preview
 * frames are not displayed.
 *
 * @throws IOException if the camera's preview texture or display could not be initialized
 */
@RequiresPermission(Manifest.permission.CAMERA)
public CameraSource start() throws IOException {
    synchronized (mCameraLock) {
        if (mCamera != null) {
            return this;
        }

        mCamera = createCamera();

        // SurfaceTexture was introduced in Honeycomb (11), so if we are running and
        // old version of Android. fall back to use SurfaceView.
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mDummySurfaceTexture = new SurfaceTexture(DUMMY_TEXTURE_NAME);
            mCamera.setPreviewTexture(mDummySurfaceTexture);
        } else {
            mDummySurfaceView = new SurfaceView(mContext);
            mCamera.setPreviewDisplay(mDummySurfaceView.getHolder());
        }
        mCamera.startPreview();

        mProcessingThread = new Thread(mFrameProcessor);
        mFrameProcessor.setActive(true);
        mProcessingThread.start();
    }
    return this;
}
项目:CSipSimple    文件:ViERenderer.java   
public static SurfaceView CreateRenderer(Context context,
        boolean useOpenGLES2) {
    if(useOpenGLES2 == true && ViEAndroidGLES20.IsSupported(context))
        return new ViEAndroidGLES20(context);
    else
        return new SurfaceView(context);
}
项目:vlc-example-streamplayer    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
  setContentView(R.layout.activity_main);
  SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);
  bStartStop = (Button) findViewById(R.id.b_start_stop);
  bStartStop.setOnClickListener(this);
  etEndpoint = (EditText) findViewById(R.id.et_endpoint);
  vlcVideoLibrary = new VlcVideoLibrary(this, this, surfaceView);
}
项目:SWDemo    文件:GridVideoViewContainer.java   
private boolean initAdapter(int localUid, HashMap<Integer, SurfaceView> uids) {
    if (mGridVideoViewContainerAdapter == null) {
        mGridVideoViewContainerAdapter = new GridVideoViewContainerAdapter(getContext(), localUid, uids, mEventListener);
        mGridVideoViewContainerAdapter.setHasStableIds(true);
        return true;
    }
    return false;
}
项目:CSipSimple    文件:SipService.java   
private void setRenderVideoWindow(final int callId, final SurfaceView window) {
    getExecutor().execute(new SipRunnable() {
        @Override
        protected void doRun() throws SameThreadException {
            pjService.setVideoAndroidRenderer(callId, window);
        }
    });
}
项目:CSipSimple    文件:SipService.java   
private void setCaptureVideoWindow(final SurfaceView window) {
    getExecutor().execute(new SipRunnable() {
        @Override
        protected void doRun() throws SameThreadException {
            pjService.setVideoAndroidCapturer(window);
        }
    });
}
项目:renderscript_examples    文件:MainActivity.java   
private void example() {
    // Prevent window dimming
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // Initialize accelerometer
    sensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
    sensorAccelerometer = sensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
    sensorManager.registerListener(this, sensorAccelerometer, SensorManager.SENSOR_DELAY_NORMAL);

    // Initializes RenderScript context
    initRenderScript();

    // Here we get our TextureView, and apply a hack (setScaleX) to enable smoothing of the
    // final output image
    SurfaceView surfaceView = (SurfaceView) findViewById(R.id.surfaceView);

    // Sets surface callback, to understand when the surface will be available
    surfaceView.getHolder().addCallback(mSurfaceViewCallback);

    surfaceView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // After touching the surface, application will end.
            if (rsLoop != null)
                rsLoop.interrupt();

            System.exit(0);
        }
    });
}
项目:SWDemo    文件:UserStatusData.java   
public UserStatusData(int uid, SurfaceView view, Integer status, int volume, VideoInfoData i) {
    this.mUid = uid;
    this.mView = view;
    this.mStatus = status;
    this.mVolume = volume;
    this.mVideoInfo = i;
}
项目:TubiPlayer    文件:TubiExoPlayerView.java   
/**
     * Set the {@link SimpleExoPlayer} to use. The {@link SimpleExoPlayer#setTextOutput} and
     * {@link SimpleExoPlayer#setVideoListener} method of the player will be called and previous
     * assignments are overridden.
     * <p>
     * @param player The {@link SimpleExoPlayer} to use.
     */
    public void setPlayer(SimpleExoPlayer player, @NonNull TubiPlaybackInterface playbackInterface) {
        setPlaybackInterface(playbackInterface);
        if (this.player == player) {
            return;
        }
        if (this.player != null) {
            this.player.removeListener(componentListener);
            this.player.clearTextOutput(componentListener);
            this.player.clearVideoListener(componentListener);
            if (surfaceView instanceof TextureView) {
                this.player.clearVideoTextureView((TextureView) surfaceView);
            } else if (surfaceView instanceof SurfaceView) {
                this.player.clearVideoSurfaceView((SurfaceView) surfaceView);
            }
        }
        this.player = player;
        if (useController) {
            controller.setPlayer(player,this, playbackInterface);
        }
        if (shutterView != null) {
            shutterView.setVisibility(VISIBLE);
        }
        if (player != null) {
            if (surfaceView instanceof TextureView) {
                player.setVideoTextureView((TextureView) surfaceView);
            } else if (surfaceView instanceof SurfaceView) {
                player.setVideoSurfaceView((SurfaceView) surfaceView);
            }
            player.setVideoListener(componentListener);
            player.setTextOutput(componentListener);
            player.addListener(componentListener);
//            maybeShowController(false);
            updateForCurrentTrackSelections();
        } else {
            hideController();
            hideArtwork();
        }
    }
项目:SWDemo    文件:WorkerThread.java   
@Override
public void handleMessage(Message msg) {
    if (this.mWorkerThread == null) {
        log.warn("handler is already released! " + msg.what);
        return;
    }

    switch (msg.what) {
        case ACTION_WORKER_THREAD_QUIT:
            mWorkerThread.exit();
            break;
        case ACTION_WORKER_JOIN_CHANNEL:
            String[] data = (String[]) msg.obj;
            mWorkerThread.joinChannel(data[0], msg.arg1, data[1]);
            break;
        case ACTION_WORKER_LEAVE_CHANNEL:
            String channel = (String) msg.obj;
            mWorkerThread.leaveChannel(channel);
            break;
        case ACTION_WORKER_CONFIG_ENGINE_CON:
            Object[] configData = (Object[]) msg.obj;
            mWorkerThread.configEngineCon((int) configData[0], (String) configData[1], (String) configData[2]);
            break;
        case ACTION_WORKER_PREVIEW:
            Object[] previewData = (Object[]) msg.obj;
            mWorkerThread.preview((boolean) previewData[0], (SurfaceView) previewData[1], (int) previewData[2]);
            break;
        case ACTION_WORKER_CONFIG_ENGINE_LIVE:
            Object[] configLiveData = (Object[]) msg.obj;
            mWorkerThread.configEngineLive((int) configLiveData[0], (int) configLiveData[1]);
            break;
        case ACTION_WORKER_JOIN_LIVE_CHANNEL:
            String[] joinLiveConfig = (String[]) msg.obj;
            mWorkerThread.joinLiveChannel(joinLiveConfig[0], msg.arg1, joinLiveConfig[1]);
            break;
    }
}
项目:FaceFilter    文件:CameraSourcePreview.java   
public CameraSourcePreview(Context context, AttributeSet attrs) {
    super(context, attrs);
    mContext = context;
    mStartRequested = false;
    mSurfaceAvailable = false;

    mSurfaceView = new SurfaceView(context);
    mSurfaceView.getHolder().addCallback(new SurfaceCallback());
    addView(mSurfaceView);
}