Apprendre
Classe de moteur
CaptureService
Création impossible
Service

*Ce contenu est traduit en utilisant l'IA (Beta) et peut contenir des erreurs. Pour consulter cette page en anglais, clique ici.


Résumé
Méthodes
CaptureScreenshot(onCaptureReady: function):()
PromptSaveCapturesToGallery(captures: {any},resultCallback: function):()
PromptShareCapture(captureContent: Content,launchData: string,onAcceptedCallback: function,onDeniedCallback: function):()
ReadCapturesFromGalleryAsync(captureTypeFilters: {any},readFromAllEligibleExperiences: boolean):Tuple
TakeScreenshotCaptureAsync(onCaptureReady: function,captureParams: Dictionary):()
Membres hérités

Référence API
Méthodes
CaptureScreenshot
Capacités : Capture
CaptureService:CaptureScreenshot(onCaptureReady:function):()
Paramètres
onCaptureReady:function
Retours
()

CheckUploadCaptureStatusAsync
Rendement
Capacités : Capture
CaptureService:CheckUploadCaptureStatusAsync(token:string):Tuple
Paramètres
token:string
Retours

PromptCaptureGalleryPermissionAsync
Rendement
Capacités : Capture
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
Paramètres
captureGalleryPermission:Enum.CaptureGalleryPermission
Retours
Échantillons de code
Invite à accéder à la galerie de captures
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
end

PromptSaveCapturesToGallery
Capacités : Capture
CaptureService:PromptSaveCapturesToGallery(
captures:{any}, resultCallback:function
):()
Paramètres
captures:{any}
resultCallback:function
Retours
()

PromptShareCapture
Capacités : Capture
CaptureService:PromptShareCapture(
captureContent:Content, launchData:string, onAcceptedCallback:function, onDeniedCallback:function
):()
Paramètres
captureContent:Content
launchData:string
onAcceptedCallback:function
onDeniedCallback:function
Retours
()

ReadCapturesFromGalleryAsync
Rendement
Capacités : Capture
CaptureService:ReadCapturesFromGalleryAsync(
captureTypeFilters:{any}, readFromAllEligibleExperiences:boolean
Paramètres
captureTypeFilters:{any}
Valeur par défaut : "{}"
readFromAllEligibleExperiences:boolean
Valeur par défaut : false
Retours
Échantillons de code
Lire les captures de la galerie et itérer sur les 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
-- Probablement une erreur de permissions, voir CaptureService:PromptCaptureGalleryPermissionAsync()
warn("Échec de la récupération des captures initiales : " .. result.Name)
return
end
-- Itérer à travers la page actuelle
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- Avancer à la page suivante jusqu'à la fin
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
end

StartUploadCaptureAsync
Rendement
Capacités : Capture
CaptureService:StartUploadCaptureAsync(capture:Capture):Tuple
Paramètres
capture:Capture
Retours

StartVideoCaptureAsync
Rendement
Capacités : Capture
CaptureService:StartVideoCaptureAsync(
onCaptureReady:function, captureParams:Dictionary
Paramètres
onCaptureReady:function
captureParams:Dictionary
Valeur par défaut : "nil"

StopVideoCapture
Capacités : Capture
CaptureService:StopVideoCapture():()
Retours
()

TakeScreenshotCaptureAsync
Capacités : Capture
CaptureService:TakeScreenshotCaptureAsync(
onCaptureReady:function, captureParams:Dictionary
):()
Paramètres
onCaptureReady:function
captureParams:Dictionary
Valeur par défaut : "nil"
Retours
()

UploadCaptureAsync
Rendement
Capacités : Capture
CaptureService:UploadCaptureAsync(capture:Capture):Tuple
Paramètres
capture:Capture
Retours
Échantillons de code
Télécharger une capture dans le système d'actifs
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
-- Gérer l'échec
return nil
end
return assetId
end)
if not success then
-- Gérer l'erreur
return nil
end
return result
end

Événements
CaptureBegan
Capacités : Capture
CaptureService.CaptureBegan(captureType:Enum.CaptureType):RBXScriptSignal
Paramètres
captureType:Enum.CaptureType

CaptureEnded
Capacités : Capture
CaptureService.CaptureEnded(captureType:Enum.CaptureType):RBXScriptSignal
Paramètres
captureType:Enum.CaptureType

CaptureSaved
Déprécié

UserCaptureSaved
Capacités : Capture
CaptureService.UserCaptureSaved(captureContentId:ContentId):RBXScriptSignal
Paramètres
captureContentId:ContentId

©2026 Société Roblox. Roblox, le logo Roblox et Powering Imagination font partie de nos marques déposées aux États-Unis et dans d'autres pays.