Engine Class
CaptureService
Summary
Methods
CaptureScreenshot(onCaptureReady: function):() |
CheckUploadCaptureStatusAsync(token: string):Tuple |
PromptCaptureGalleryPermissionAsync(captureGalleryPermission: Enum.CaptureGalleryPermission):boolean |
PromptSaveCapturesToGallery(captures: {any},resultCallback: function):() |
PromptShareCapture(captureContent: Content,launchData: string,onAcceptedCallback: function,onDeniedCallback: function):() |
ReadCapturesFromGalleryAsync(captureTypeFilters: {any},readFromAllEligibleExperiences: boolean):Tuple |
StartUploadCaptureAsync(capture: Capture):Tuple |
StartVideoCaptureAsync(onCaptureReady: function,captureParams: Dictionary):Enum.VideoCaptureStartedResult |
StopVideoCapture():() |
TakeScreenshotCaptureAsync(onCaptureReady: function,captureParams: Dictionary):() |
UploadCaptureAsync(capture: Capture):Tuple |
Events
CaptureBegan(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureEnded(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureSaved(captureInfo: Dictionary):RBXScriptSignal |
UserCaptureSaved(captureContentId: ContentId):RBXScriptSignal |
API Reference
Methods
CaptureScreenshot
CheckUploadCaptureStatusAsync
PromptCaptureGalleryPermissionAsync
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
Parameters
Returns
Code Samples
Prompt capture gallery permission
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
endPromptSaveCapturesToGallery
ReadCapturesFromGalleryAsync
Returns
Code Samples
Read captures from gallery and iterate over pages
local CaptureService = game:GetService("CaptureService")
local function readCapturesFromGallery()
local allCaptures = {}
local capturesPages
local success, result = pcall(function()
local readResult, pages = CaptureService:ReadCapturesFromGalleryAsync({}, false)
if readResult == Enum.ReadCapturesFromGalleryResult.Success then
capturesPages = pages
end
return readResult
end)
if not success or result ~= Enum.ReadCapturesFromGalleryResult.Success then
-- Likely a permissions error, see CaptureService:PromptCaptureGalleryPermissionAsync()
warn("Failed to fetch initial captures: " .. result.Name)
return
end
-- Iterate through current page
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- Advance to next page until finished
while not capturesPages.IsFinished do
local advanceToNextPageSuccess, _ = pcall(function()
capturesPages:AdvanceToNextPageAsync()
end)
if not advanceToNextPageSuccess then
return
end
currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
end
return allCaptures
endStartUploadCaptureAsync
StartVideoCaptureAsync
CaptureService:StartVideoCaptureAsync(
Parameters
| Default Value: "nil" |
StopVideoCapture
CaptureService:StopVideoCapture():()
Returns
()
TakeScreenshotCaptureAsync
Parameters
| Default Value: "nil" |
Returns
()
UploadCaptureAsync
Parameters
Returns
Code Samples
Upload capture to asset system
local CaptureService = game:GetService("CaptureService")
local function uploadCapture(capture: Capture)
local success, result = pcall(function()
local uploadCaptureResult, assetId = CaptureService:UploadCaptureAsync(capture)
if uploadCaptureResult ~= Enum.UploadCaptureResult.Success then
-- Handle failure
return nil
end
return assetId
end)
if not success then
-- Handle error
return nil
end
return result
endEvents
CaptureBegan
Parameters
CaptureEnded
Parameters
CaptureSaved
UserCaptureSaved
Parameters
captureContentId:ContentId |