Capture Service
概要
方法
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 |
イベント
CaptureBegan(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureEnded(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureSaved(captureInfo: Dictionary):RBXScriptSignal |
UserCaptureSaved(captureContentId: ContentId):RBXScriptSignal |
APIリファレンス
方法
Capture Screenshot
パラメータ
戻り値
()
コードサンプル
スクリーンショットをキャプチャ
local CaptureService = game:GetService("CaptureService")
-- このコードを含むスクリプトの親である ImageLabel への参照
local imageLabel = script.Parent
local function onCaptureReady(contentId)
imageLabel.Image = contentId
end
CaptureService:CaptureScreenshot(onCaptureReady)Check Upload Capture Status Async
Prompt Capture Gallery Permission Async
Capture Service: Prompt Capture Gallery Permission Async(capture Gallery Permission:Enum.CaptureGalleryPermission):boolean
パラメータ
戻り値
コードサンプル
キャプチャギャラリーのアクセス許可を要求
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
-- ギャラリーへのアクセスが許可されているか確認します
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
end
print(isGalleryAccessGranted())Prompt Save Captures To Gallery
戻り値
()
コードサンプル
プロンプト共有キャプチャ
local CaptureService = game:GetService("CaptureService")
local function onShareAccepted()
print("キャプチャ共有が承認されました!")
end
local function onShareDenied()
print("キャプチャ共有が拒否されました!")
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, {})Read Captures From Gallery Async
戻り値
コードサンプル
ギャラリーからキャプチャを読み取り、ページを繰り返す
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
-- おそらく権限エラーです。CaptureService:PromptCaptureGalleryPermissionAsync()を参照してください。
warn("初期キャプチャの取得に失敗しました: " .. result.Name)
return
end
-- 現在のページを反復処理します
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- 完了するまで次のページに進みます
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
local captures = readCapturesFromGallery()
print(captures)Start Upload Capture Async
Start Video Capture Async
Capture Service: Start Video Capture Async(
パラメータ
| 既定値: nil |
コードサンプル
ビデオキャプチャを非同期で開始
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("ビデオ録画が理由により完了しませんでした:", result)
else
-- ユーザーにビデオキャプチャをギャラリーに保存するよう促す
CaptureService:PromptSaveCapturesToGallery({ videoCapture }, function()
print("キャプチャが保存されました")
end)
end
end
tool.Activated:Connect(function()
local videoRecordingAllowedResult: Enum.VideoCaptureStartedResult = CaptureService:StartVideoCaptureAsync(onCaptureReady, {})
if videoRecordingAllowedResult ~= Enum.VideoCaptureStartedResult.Success then
print("ビデオ録画が理由により開始できませんでした:", videoRecordingAllowedResult)
end
end)Stop Video Capture
Capture Service: Stop Video Capture():()
戻り値
()
Take Screenshot Capture Async
パラメータ
| 既定値: nil |
戻り値
()
コードサンプル
スクリーンショットキャプチャ非同期
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("スクリーンショットの完了に失敗しました。理由:", result)
else
-- ユーザーにスクリーンショットキャプチャをギャラリーに保存するように促します
CaptureService:PromptSaveCapturesToGallery({ screenshotCapture }, function(results)
for capture, result in pairs(results) do
if result then
print("キャプチャが保存されました")
end
end
end)
end
end
parent.Activated:Connect(function()
CaptureService:TakeScreenshotCaptureAsync(onCaptureReady, { UICaptureMode = Enum.UICaptureMode.All })
end)Upload Capture Async
パラメータ
戻り値
コードサンプル
アセットシステムにキャプチャをアップロード
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
-- 失敗を処理する
return nil
end
return assetId
end)
if not success then
-- エラーを処理する
return nil
end
return result
end
CaptureService:TakeScreenshotCaptureAsync(function(result, screenshotCapture)
if result == Enum.ScreenshotCaptureResult.Success and screenshotCapture then
print(uploadCapture(screenshotCapture))
end
end)イベント
Capture Began
パラメータ
Capture Ended
パラメータ
Capture Saved
User Capture Saved
パラメータ
captureContentId:ContentId |