public void init(Context context) { View.inflate(context, getLayoutId(), this); startButton = findViewById(R.id.start); fullscreenButton = findViewById(R.id.fullscreen); progressBar = findViewById(R.id.bottom_seek_progress); currentTimeTextView = findViewById(R.id.current); totalTimeTextView = findViewById(R.id.total); bottomContainer = findViewById(R.id.layout_bottom); textureViewContainer = findViewById(R.id.surface_container); topContainer = findViewById(R.id.layout_top); startButton.setOnClickListener(this); fullscreenButton.setOnClickListener(this); progressBar.setOnSeekBarChangeListener(this); bottomContainer.setOnClickListener(this); textureViewContainer.setOnClickListener(this); textureViewContainer.setOnTouchListener(this); mScreenWidth = getContext().getResources().getDisplayMetrics().widthPixels; mScreenHeight = getContext().getResources().getDisplayMetrics().heightPixels; mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); try { if (isCurrentPlay()) { NORMAL_ORIENTATION = ((AppCompatActivity) context).getRequestedOrientation(); } } catch (Exception e) { e.printStackTrace(); } }
private void init(Context context) { textureViewContainer = new FrameLayout(getContext()); textureViewContainer.setBackgroundColor(Color.BLACK); LayoutParams params = new LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); addView(textureViewContainer, TEXTURE_VIEW_POSITION, params); try { mScreenOrientation = ((AppCompatActivity) context).getRequestedOrientation(); } catch (Exception e) { e.printStackTrace(); } }
public static int getRequestedOrientation(Context context) { if (getAppCompActivity(context) != null) { return getAppCompActivity(context).getRequestedOrientation(); } else { return scanForActivity(context).getRequestedOrientation(); } }
protected void init(Context context, AttributeSet attrs) { View.inflate(context, attachLayoutRes(), this); orientationNormal = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; orientationFullScreen = ActivityInfo.SCREEN_ORIENTATION_SENSOR; screenType = ScreenType.SCREEN_TYPE_ADAPTER; iv_play = findViewById(R.id.iplayer_iv_play); iv_fullscreen = findViewById(R.id.iplayer_iv_fullscreen); sb_bottom = findViewById(R.id.iplayer_sb_bottom); tv_current_time = findViewById(R.id.iplayer_tv_current_time); tv_total_time = findViewById(R.id.iplayer_tv_total_time); ll_bottom = findViewById(R.id.iplayer_ll_bottom); fl_surface = findViewById(R.id.iplayer_fl_surface); ll_top = findViewById(R.id.iplayer_ll_top); iv_play.setOnClickListener(this); iv_fullscreen.setOnClickListener(this); sb_bottom.setOnSeekBarChangeListener(this); ll_bottom.setOnClickListener(this); fl_surface.setOnClickListener(this); fl_surface.setOnTouchListener(this); screenWidth = getContext().getResources().getDisplayMetrics().widthPixels; screenHeight = getContext().getResources().getDisplayMetrics().heightPixels; audioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); try { if (isCurrentPlayer()) { orientationNormal = ((AppCompatActivity) context).getRequestedOrientation(); } } catch (Exception e) { e.printStackTrace(); } }