반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- setBackgroundResource
- Android Studio 3.6
- 코틀린
- 금속 탐지기 센서
- 회전 센서
- 자격증
- 걸음 감지 센서
- lateinit
- Android
- Kotlin
- mysql 5.7
- 광 센서
- LayoutParmas
- 온라인IDE
- 온라인무료코딩사이트
- powercfg
- BottomSheetDialog
- 온라인에디터
- 자기장 센서
- utf8mb4
- Aplha
- RecyclerView
- phpstorm
- 걸음수 감지 센서
- 동영상 실행
- 웹코드빌드
- 온라인코딩
- Exoplayer
- ARGB
Archives
- Today
- Total
Memory
[ANDROID] ExoPlayer Controller Layout Custom하기 (r2.12.2) 본문
반응형
<이전 글>
2021/01/12 - [IT/ANDROID] - [ANDROID/KOTLIN] ExoPlayer로 동영상 실행하기 (r2.12.2)
XML (exo_playback_control_view.xml) - Custom ExoPlayer Controller Layout
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constraintL_control"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_80000000">
<ImageButton
android:id="@id/exo_rew"
style="@style/ExoMediaButton.Rewind"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="32dp"
android:background="@null"
android:contentDescription="@string/previous"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="@+id/constraintL_start_pause"
app:layout_constraintEnd_toStartOf="@+id/constraintL_start_pause"
app:layout_constraintTop_toTopOf="@+id/constraintL_start_pause"
app:srcCompat="@drawable/selector_video_previous" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintL_start_pause"
android:layout_width="64dp"
android:layout_height="64dp"
app:layout_constraintBottom_toBottomOf="@+id/exo_progress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageButton
android:id="@id/exo_play"
style="@style/ExoMediaButton.Play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="@string/start"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:drawable/ic_media_play"/>
<ImageButton
android:id="@id/exo_pause"
style="@style/ExoMediaButton.Pause"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="@string/pause"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@android:drawable/ic_media_pause" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageButton
android:id="@id/exo_ffwd"
style="@style/ExoMediaButton.FastForward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:background="@null"
android:contentDescription="@string/next"
android:padding="16dp"
app:layout_constraintBottom_toBottomOf="@+id/constraintL_start_pause"
app:layout_constraintStart_toEndOf="@+id/constraintL_start_pause"
app:layout_constraintTop_toTopOf="@+id/constraintL_start_pause"
app:srcCompat="@drawable/selector_video_next" />
<com.google.android.exoplayer2.ui.DefaultTimeBar
android:id="@+id/exo_progress"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/exo_position"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
android:text="@string/text_example"
android:textColor="@color/white"
app:layout_constraintBottom_toTopOf="@+id/exo_progress"
app:layout_constraintEnd_toStartOf="@+id/exo_duration"
app:layout_constraintStart_toStartOf="@+id/exo_progress" />
<TextView
android:id="@+id/exo_duration"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="@string/text_example"
android:textAlignment="textEnd"
android:textColor="@color/white"
app:layout_constraintBottom_toTopOf="@+id/exo_progress"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/exo_position" />
</androidx.constraintlayout.widget.ConstraintLayout>
※ ExoPlayer 내부에 설정되어있는 id를 사용해야 정상 동작됩니다.
<item name="exo_ad_overlay" type="id"/>
<item name="exo_artwork" type="id"/>
<item name="exo_buffering" type="id"/>
<item name="exo_content_frame" type="id"/>
<item name="exo_controller" type="id"/>
<item name="exo_controller_placeholder" type="id"/>
<item name="exo_duration" type="id"/>
<item name="exo_error_message" type="id"/>
<item name="exo_ffwd" type="id"/>
<item name="exo_next" type="id"/>
<item name="exo_overlay" type="id"/>
<item name="exo_pause" type="id"/>
<item name="exo_play" type="id"/>
<item name="exo_position" type="id"/>
<item name="exo_prev" type="id"/>
<item name="exo_progress" type="id"/>
<item name="exo_repeat_toggle" type="id"/>
<item name="exo_rew" type="id"/>
<item name="exo_shuffle" type="id"/>
<item name="exo_shutter" type="id"/>
<item name="exo_subtitles" type="id"/>
<item name="exo_vr" type="id"/>
XML (activity_video_detail.xml) - ExoPlayer 가 포함된 레이아웃
controller_layout_id에 바꾸고자 하는 레이아웃를 넣어준다!
app:controller_layout_id="@layout/exo_playback_control_view"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/white"
tools:context=".activity.VideoDetailActivity">
<FrameLayout
android:id="@+id/frameL_video_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- 기본
빨리감기 / 되감기 : 15초
-->
<!-- Custom
show_timeout : PlayerView사용자가 마지막으로 상호 작용 한 후 컨트롤이 숨겨지기 전까지의 지연 시간
빨리감기(fastforward_increment) / 되감기(rewind_increment) : 10초
-->
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/exoPlayerV_video_detail"
android:layout_width="match_parent"
android:layout_height="210dp"
app:controller_layout_id="@layout/exo_playback_control_view"
app:fastforward_increment="10000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:resize_mode="zoom"
app:rewind_increment="10000"
app:show_timeout="10000" />
<ImageButton
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:contentDescription="@string/icon_back"
android:padding="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ico_back_white" />
</FrameLayout>
...
</LinearLayout>
[참고]
출처 -
무작정 앱만들기 -6 (ExoPlayer로 간단한 뮤직 플레이어를 만들어보자)
여러 개의 영상을 Exoplayer로 순차 재상하기
반응형
'IT > ANDROID' 카테고리의 다른 글
[ANDROID/KOTLIN] 일주일 날짜 구하기 (1) | 2021.01.23 |
---|---|
[ANDROID/KOTLIN] 태블릿 기기인지 코드로 확인하는 방법 (0) | 2021.01.23 |
[ANDROID] ExoPlayer 영상 꽉차게 표시하기 (0) | 2021.01.19 |
[ANDROID/KOTLIN] ExoPlayer로 YouTube 영상 실행하기 (2) | 2021.01.18 |
[ANDROID/KOTLIN] ExoPlayer로 동영상 실행하기 (r2.12.2) (0) | 2021.01.12 |