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
()
Échantillons de code
Capturer une capture d'écran
local CaptureService = game:GetService("CaptureService")
-- Référence à un ImageLabel parent du script contenant ce code
local imageLabel = script.Parent
local function onCaptureReady(contentId)
imageLabel.Image = contentId
end
CaptureService:CaptureScreenshot(onCaptureReady)

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
()
Échantillons de code
Demande de partage de capture
local CaptureService = game:GetService("CaptureService")
local function onShareAccepted()
print("Le partage de capture a été accepté !")
end
local function onShareDenied()
print("Le partage de capture a été refusé !")
end
local onCaptureReady = function(result, videoCapture)
if videoCapture then
local captureContent = Content.fromObject(videoCapture)
CaptureService:PromptShareCapture(captureContent, "launchData" , onShareAccepted, onShareDenied)
end
end
CaptureService:StartVideoCaptureAsync(onCaptureReady, {})

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"
Échantillons de code
Démarrer l'enregistrement vidéo asynchrone
local CaptureService = game:GetService("CaptureService")
local tool = Instance.new("Tool")
tool.Parent = workspace
local onCaptureReady = function(result, videoCapture)
if result ~= Enum.VideoCaptureResult.Success and result ~= Enum.VideoCaptureResult.TimeLimitReached or not videoCapture then
print("L'enregistrement vidéo n'a pas pu se terminer pour la raison :", result)
else
-- Inviter l'utilisateur à enregistrer la capture vidéo dans sa galerie
CaptureService:PromptSaveCapturesToGallery({ videoCapture }, function()
print("Capture enregistrée")
end)
end
end
tool.Activated:Connect(function()
local videoRecordingAllowedResult: Enum.VideoCaptureStartedResult = CaptureService:StartVideoCaptureAsync(onCaptureReady, {})
if videoRecordingAllowedResult ~= Enum.VideoCaptureStartedResult.Success then
print("L'enregistrement vidéo n'a pas pu démarrer pour la raison :", videoRecordingAllowedResult)
end
end)

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
()
Échantillons de code
Prendre une capture d'écran de manière asynchrone
local CaptureService = game:GetService("CaptureService")
local parent = Instance.new("Tool")
parent.Parent = workspace
local onCaptureReady = function(result, screenshotCapture)
if result ~= Enum.ScreenshotCaptureResult.Success or not screenshotCapture then
print("La capture d'écran n'a pas pu être complétée pour la raison:", result)
else
-- Inviter l'utilisateur à enregistrer la capture d'écran dans sa galerie
CaptureService:PromptSaveCapturesToGallery({ screenshotCapture }, function(results)
for capture, result in pairs(results) do
if result then
print("Capture enregistrée")
end
end
end)
end
end
parent.Activated:Connect(function()
CaptureService:TakeScreenshotCaptureAsync(onCaptureReady, { UICaptureMode = Enum.UICaptureMode.All })
end)

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.