콘텐츠 녹화 지원
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
TV 입력 서비스를 사용하면 사용자가 입력 장치를 사용하여 채널 재생을
타임 시프팅 API를
사용하는 것이 좋습니다.
타임 시프팅에서 Android 7.0 확장
여러 개의 녹화된 세션을 저장할 수 있습니다.
사용자는 미리 녹화를 예약하거나 시청하면서 녹화를 시작할 수 있음
프로그램을 만드는 것입니다. 시스템에서 녹음 파일을 저장하면 사용자는 기록을 탐색, 관리,
시스템 TV 앱을 사용하여 녹화 파일을 재생합니다.
TV 입력 서비스에 녹화 기능을 제공하려면
앱에서 녹화를 지원한다는 것을 시스템에 명시해야 합니다.
프로그램을 녹화하고 발생하는 모든 오류를 처리 및 전달하는 능력
및 녹화된 세션을 관리할 수 있습니다.
녹화 지원 알리기
TV 입력 서비스가 녹화를 지원한다고 시스템에 알리려면
서비스 메타데이터 XML 파일의 android:canRecord
속성
true
에게 다음과 같이 합니다.
<tv-input xmlns:android="http://schemas.android.com/apk/res/android"
android:canRecord="true"
android:setupActivity="com.example.sampletvinput.SampleTvInputSetupActivity" />
서비스 메타데이터 파일에 대한 자세한 내용은
TV 입력 선언
서비스에 대한 액세스를 제공합니다.
또는 다음을 사용하여 코드에 녹화 지원을 표시할 수 있습니다.
다음 단계를 따르세요.
- TV 입력 서비스
onCreate()
에서
메서드를 사용하여 새 TvInputInfo
객체를 만듭니다.
TvInputInfo.Builder
클래스.
- 새
TvInputInfo
객체를 만들 때 다음을 호출합니다.
통화 전 setCanRecord(true)
build()
:
녹화를 지원합니다.
- 다음을 호출하여
TvInputInfo
객체를 시스템에 등록합니다.
TvInputManager.updateTvInputInfo()
입니다.
세션 녹화
TV 입력 서비스가 녹화를 지원한다고 등록한 후
기능을 사용하면 시스템에서
TvInputService.onCreateRecordingSession()
메서드(액세스가 필요한 경우)
앱의 녹음 구현을 고려해야 합니다. 자체 구현
TvInputService.RecordingSession
서브클래스를 가져오고 반환
onCreateRecordingSession()
콜백이 실행될 때 이 서브클래스는
올바른 채널 데이터로 전환하고, 요청된 데이터를 녹화하고,
시스템에 기록 상태 및 오류를 전달해야 합니다.
시스템에서
RecordingSession.onTune()
: 채널 URI를 전달하고 채널에 맞춥니다.
지정할 수 있습니다. 앱이
원하는 채널을
notifyTuned()
를 호출하거나, 앱이 적절한 채널에 맞출 수 없는 경우 다음을 호출합니다.
notifyError()
입니다.
그런 다음 시스템은
RecordingSession.onStartRecording()
콜백입니다. 앱에서 녹화를 시작해야 합니다.
즉시 삭제할 수 있습니다 시스템은 이 콜백을 호출할 때
녹화될 프로그램에 대한 정보가 들어 있습니다.
녹화가 완료되면 이 데이터를
RecordedPrograms
데이터 표입니다.
마지막으로 시스템은
RecordingSession.onStopRecording()
이 시점에서 앱이 중지되고
즉시 녹화됩니다. 또한
RecordedPrograms
RecordedPrograms.COLUMN_RECORDING_DATA_URI
열 및 모든 프로그램
첫 호출에서 시스템이 제공한 정보
onStartRecording()
입니다.
자세한 내용은
RecordedPrograms
테이블,
녹화된 세션 관리 섹션을 참고하세요.
녹화 오류 처리
녹화 중에 오류가 발생하여 녹화된 데이터를 사용할 수 없게 되는 경우
다음을 호출하여 시스템에 알립니다.
notifyError()
또는
녹화 세션이 생성된 후 notifyError()
로 설정하여 시스템에 알립니다.
더 이상 세션을 녹화할 수 없습니다.
녹화 중에 오류가 발생했지만
사용자에게 재생하거나 통화하기 위해 부분 녹음 파일을
notifyRecordingStopped()
: 시스템에서 다음 작업을 할 수 있도록 합니다.
부분 세션을 사용합니다.
녹화된 세션 관리
시스템은 모든 활동에서 기록된 모든 세션에 대해
녹화 가능한 채널 앱을
RecordedPrograms
콘텐츠 제공자 테이블에만 포함됩니다. 이 정보는
RecordedPrograms
콘텐츠 녹화 URI입니다. 콘텐츠 제공업체 API 사용
이 테이블의 항목을 읽고 추가하고 삭제할 수 있습니다.
콘텐츠 제공자 데이터 사용에 대한 자세한 내용은 다음을 참조하세요.
<ph type="x-smartling-placeholder"></ph>
콘텐츠 제공자 기본사항
권장사항
TV 기기는 저장용량이 제한될 수 있으므로 신중하게 판단하세요.
녹화된 세션을 저장하기 위해 저장소를 할당하는 중입니다. 사용
RecordingCallback.onError(RECORDING_ERROR_INSUFFICIENT_SPACE)
인 경우
공간이 부족해 녹화된 세션을 저장할 수 없습니다.
사용자가 녹화를 시작하면 바로 데이터 녹화가 시작됩니다.
할 수 있습니다. 이를 용이하게 하려면 시간이 많이 소요되는 작업을 초기에 완료하거나
저장공간 액세스 및 할당과 같은 작업이 포함됩니다.
onCreateRecordingSession()
콜백입니다. 이렇게 하면
즉시
onStartRecording()
콜백이 실행됩니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Support content recording\n\nTV input services let the user pause and resume channel playback using\n[time-shifting APIs](/training/tv/tif/time-shifting).\nAndroid 7.0 expands on time-shifting\nby letting the user save multiple recorded sessions.\n\nUsers can schedule recordings in advance or start a recording as they watch\na program. Once the system saves a recording, the user can browse, manage,\nand play back the recording using the system TV app.\n\nIf you want to provide recording functionality for your TV input service,\nyou must indicate to the system that your app supports recording, implement\nthe ability to record programs, handle and communicate any errors that occur\nduring recording, and manage your recorded sessions.\n\nIndicate support for recording\n------------------------------\n\nTo tell the system that your TV input service supports recording, set\nthe `android:canRecord` attribute in your service metadata XML file\nto `true`: \n\n```xml\n\u003ctv-input xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:canRecord=\"true\"\n android:setupActivity=\"com.example.sampletvinput.SampleTvInputSetupActivity\" /\u003e\n```\n\nFor more information on the service metadata file, see\n[Declare your TV input\nservice in the manifest](/training/tv/tif/tvinput#manifest).\n\nAlternatively, you can indicate recording support in your code using\nthese steps:\n\n1. In your TV input service [onCreate()](/reference/android/app/Service#onCreate()) method, create a new [TvInputInfo](/reference/android/media/tv/TvInputInfo) object using the [TvInputInfo.Builder](/reference/android/media/tv/TvInputInfo.Builder) class.\n2. When creating the new `TvInputInfo` object, call [setCanRecord(true)](/reference/android/media/tv/TvInputInfo.Builder#setCanRecord(boolean)) before calling [build()](/reference/android/media/tv/TvInputInfo.Builder#build()) to indicate that your service supports recording.\n3. Register your `TvInputInfo` object with the system by calling [TvInputManager.updateTvInputInfo()](/reference/android/media/tv/TvInputManager#updateTvInputInfo(android.media.tv.TvInputInfo)).\n\nRecord a session\n----------------\n\nAfter your TV input service registers that it supports recording\nfunctionality, the system calls your\n[TvInputService.onCreateRecordingSession()](/reference/android/media/tv/TvInputService#onCreateRecordingSession(java.lang.String)) method when it needs to access\nyour app's recording implementation. Implement your own\n[TvInputService.RecordingSession](/reference/android/media/tv/TvInputService.RecordingSession) subclass and return it\nwhen the `onCreateRecordingSession()` callback fires. This subclass is responsible\nfor switching to the correct channel data, recording the requested data,\nand communicating recording status and errors to the system.\n\nWhen the system calls\n[RecordingSession.onTune()](/reference/android/media/tv/TvInputService.RecordingSession#onTune(android.net.Uri)), passing in a channel URI, tune to the channel\nthat the URI specifies. Notify the system that your app has tuned to the\ndesired channel by calling\n[notifyTuned()](/reference/android/media/tv/TvInputService.RecordingSession#notifyTuned(android.net.Uri)) or, if your app can't tune to the proper channel, call\n[notifyError()](/reference/android/media/tv/TvInputService.RecordingSession#notifyError(int)).\n\nThe system next invokes the\n[RecordingSession.onStartRecording()](/reference/android/media/tv/TvInputService.RecordingSession#onStartRecording(android.net.Uri)) callback. Your app must start recording\nimmediately. When the system invokes this callback, it might provide a URI\nthat contains information about the program that is about to be recorded.\nWhen the recording is done, copy this data to the\n[RecordedPrograms](/reference/android/media/tv/TvContract.RecordedPrograms)\ndata table.\n\nFinally, the system calls\n[RecordingSession.onStopRecording()](/reference/android/media/tv/TvInputService.RecordingSession#onStopRecording()). At this point, your app must stop\nrecording immediately. You also need to create an entry in the\n`RecordedPrograms`\ntable that includes the recorded session data URI in the\n[RecordedPrograms.COLUMN_RECORDING_DATA_URI](/reference/android/media/tv/TvContract.RecordedPrograms#COLUMN_RECORDING_DATA_URI) column, and any program\ninformation that the system provided in the initial call to\n`onStartRecording()`.\n\nFor more details on how to access the\n`RecordedPrograms` table,\nsee the [Manage recorded sessions](#sessions) section.\n\nHandle recording errors\n-----------------------\n\nIf an error occurs during recording, resulting in unusable recorded data,\nnotify the system by calling\n[notifyError()](/reference/android/media/tv/TvInputService.RecordingSession#notifyError(int)).\nYou can also call\nnotifyError() after a recording session is created to let the system know\nthat your app can no longer record sessions.\n\nIf an error occurs during recording but you want to provide a\npartial recording to users for playback, call\n[notifyRecordingStopped()](/reference/android/media/tv/TvInputService.RecordingSession#notifyRecordingStopped(android.net.Uri)) to enable the system to\nuse the partial session.\n\nManage recorded sessions\n------------------------\n\nThe system maintains information for all recorded sessions from all\nrecording-capable channel apps in the\n[RecordedPrograms](/reference/android/media/tv/TvContract.RecordedPrograms)\ncontent provider table. This information is accessible through the\nRecordedPrograms\ncontent recording URIs. Use content provider APIs to\nread, add, and delete entries from this table.\n\nFor more information on working with content provider data, see\n[Content provider basics](/guide/topics/providers/content-provider-basics).\n\nBest practices\n--------------\n\nTV devices might have limited storage, so use your best judgment when\nallocating storage to save recorded sessions. Use\n[RecordingCallback.onError(RECORDING_ERROR_INSUFFICIENT_SPACE)](/reference/android/media/tv/TvRecordingClient.RecordingCallback#onError(int)) when\nthere isn't enough space to save a recorded session.\n\nWhen the user initiates recording, start recording data as soon\nas possible. To facilitate this, complete any up-front time-consuming tasks,\nlike accessing and allocating storage space, when the system invokes the\n[onCreateRecordingSession()](/reference/android/media/tv/TvInputService#onCreateRecordingSession(java.lang.String)) callback. Doing so lets you start\nrecording immediately when the\n[onStartRecording()](/reference/android/media/tv/TvInputService.RecordingSession#onStartRecording(android.net.Uri)) callback fires."]]