Media session callbacks
https://developer.android.com/guide/topics/media-apps/video-app/mediasession-callbacks
비디오 앱이 미디어 세션과 미디어 컨트롤러를 같은 액티비티에서 실행하므로 미디어 세션 콜백은 오디오 앱 서버/클라이언트 아키텍쳐를 위한 구현과는 다르다. 서비스 콜은 없고 노티피케이션은 NotificationManager 를 통해 다뤄진다. 다음 테이블은 각 콜백 메소드에서 다양한 기능이 어떻게 제어됨을 보여준다.
onPlay() | onPause() | onStop() | |
Audio Focus | requestFocus() passing in your OnAudioFocusChangeListener .Always call requestFocus() first, proceed only if focus is granted. | abandonAudioFocus() | |
Media Session | setActive( - Update metadata and state | - Update metadata and state | setActive( - Update metadata and state |
Player Implementation | Start the player | Pause the player | Stop the player |
Becoming Noisy | Register your BroadcastReceiver | Unregister your BroadcastReceiver | |
Notifications | Show notification | Update notification |
일러두기: 필요한 콜백으로 미디어 세션을 만들면 구글 어시스턴트를 사용해 보이스 명령으로 앱을 제어할 수 있다. 이 요구사항은 Google Assistant documentation 에서 설명되어 있다.
최근 덧글