> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# XGameStreamingGetLastFrameDisplayed

> XGameStreamingGetLastFrameDisplayed

# XGameStreamingGetLastFrameDisplayed

<Info>**已淘汰。** 此 API 自 2604 GDK 版本起已淘汰，並將在未來的 GDK 版本中移除。沒有替代 API：遊戲應改用 [XGameStreamingGetStreamAddedLatency](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminggetstreamaddedlatency) 進行考量延遲的遊戲玩法調整。</Info>

取得最近在串流用戶端螢幕上顯示之畫面的畫面管線權杖。

## 語法

```cpp theme={null}
HRESULT XGameStreamingGetLastFrameDisplayed(  
         XGameStreamingClientId client,  
         D3D12XBOX_FRAME_PIPELINE_TOKEN* framePipelineToken  
)  
```

### 參數

*client*   \_In\_\
類型：XGameStreamingClientId

要查詢的串流用戶端裝置識別碼。

*framePipelineToken*   \_Out\_\
類型：D3D12XBOX\_FRAME\_PIPELINE\_TOKEN\*

最後在用戶端裝置上顯示的畫面管線權杖。

### 傳回值

類型：HRESULT

如果成功，則傳回 **S\_OK**；否則傳回錯誤碼。

#### 可能的錯誤

| 錯誤碼 | 錯誤值 | 錯誤原因 |
| - | - | - |
| E\_GAMESTREAMING\_NOT\_INITIALIZED | 0x89245400 | XGameStreaming 執行階段尚未初始化。請先呼叫 [XGameStreamingInitialize](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminginitialize)，再呼叫其他 API。 |
| E\_GAMESTREAMING\_CLIENT\_NOT\_CONNECTED | 0x89245401 | 指定的用戶端未連線。 |
| E\_GAMESTREAMING\_NO\_DATA | 0x89245402 | 要求的資料無法使用。資料稍後可能會可供使用。 |

## 備註

當玩家正在串流遊戲時，如果遊戲需要在確認特定畫面已顯示在使用者螢幕上之後變更遊戲行為，可以使用 `XGameStreamingGetLastFrameDisplayed`。

遊戲可能會使用此功能的一些範例包括：

* 視覺計時器已到期，而玩家在到期前未採取任何動作。
* 未在適當的時間範圍內採取動作。
* 玩家持續移動到邊界外，且未採取動作來恢復。

當嘗試判斷應該在何時採取某個動作但並未採取時，應使用 `XGameStreamingGetLastFrameDisplayed`。如果遊戲需要判斷玩家**確實**進行輸入時所顯示的內容，遊戲應使用 [XGameStreamingGetAssociatedFrame](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe)。

## 範例

```C++ theme={null}
// In this example, when processing input, the game would like to pass along the last frame 
// that was being displayed to the player so that their simulation engine can take that into account.
 

// The framePipelineToken was initially captured at the callback of WaitFrameEventX

void Game::Update(DX::StepTimer const& timer)
{
    ...

    D3D12XBOX_FRAME_PIPELINE_TOKEN framePipelineToken = D3D12XBOX_FRAME_PIPELINE_TOKEN_NULL;
    if SUCCEEDED(XGameStreamingGetLastFrameDisplayed(clientId, &framePipelineToken)
    {
        SimulateBasedOnLastFrameDisplayed(framePipelineToken);
    }
    else 
    {
        // don't have last token, potentially simulate based on current frame

        SimulateBasedOnCurrentFrame();
    }

    
      
    ...
}

```

## 需求

**標頭：** xgamestreaming.h

**程式庫：** xgameruntime.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 概念文件

* [遊戲串流延遲補償深入探討](/zh-TW/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive)

## 另請參閱

[XGameStreamingGetAssociatedFrame](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe)\
[XGameStreaming](/zh-TW/reference/system/xgamestreaming/xgamestreaming_members#Latency)\
[遊戲串流延遲補償概觀](/zh-TW/build/core-features/common/game-streaming/game-streaming-latency-compensation-overview)


## Related topics

- [XGameStreamingGetAssociatedFrame](/zh-TW/reference/system/xgamestreaming/functions/xgamestreaminggetassociatedframe.md)
- [遊戲串流延遲補償深入探討](/zh-TW/build/core-features/common/game-streaming/game-streaming-latency-compensation-deep-dive.md)
- [XGameStreaming](/zh-TW/reference/system/xgamestreaming/xgamestreaming_members.md)
- [適用於 GDK 的 Unity C# API 包裝函式](/zh-TW/build/gdk-and-engines/unity/unity-api-wrappers.md)
- [GetLastXmaFrameBitPosition](/zh-TW/reference/audio/xma2defs/functions/getlastxmaframebitposition.md)
