Classe de moteur
CaptureService
*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):() |
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 |
Événements
CaptureBegan(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureEnded(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureSaved(captureInfo: Dictionary):RBXScriptSignal |
UserCaptureSaved(captureContentId: ContentId):RBXScriptSignal |
Référence API
Méthodes
CaptureScreenshot
CheckUploadCaptureStatusAsync
PromptCaptureGalleryPermissionAsync
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
Paramètres
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
endPromptSaveCapturesToGallery
ReadCapturesFromGalleryAsync
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
endStartUploadCaptureAsync
StartVideoCaptureAsync
CaptureService:StartVideoCaptureAsync(
Paramètres
| Valeur par défaut : "nil" |
StopVideoCapture
CaptureService:StopVideoCapture():()
Retours
()
TakeScreenshotCaptureAsync
Paramètres
| Valeur par défaut : "nil" |
Retours
()
UploadCaptureAsync
Paramètres
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
Paramètres
CaptureEnded
Paramètres
CaptureSaved
UserCaptureSaved
Paramètres
captureContentId:ContentId |