as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
AWS
文档
Support
Contact Us
My Cases
新手入门
设计和开发
应用发布
参考
支持
跳转到主要内容

Create VideoPlaybackScreen

The next functionality that we want to add to the app, is the ability to launch a video player. For this tutorial, you’ll create a dedicated VideoPlaybackScreen that can host your preferred video player component. We recommend using the W3C Media API for its cross-platform compatibility and standardized interface, though you’re free to integrate any supported player that meets your requirements.
  • Create a new file called VideoPlaybackScreen.tsx in the screens folder.
  • Open the VideoPlaybackScreen.tsx and add our import statements for React, View, and StyleSheet from ‘react-native’, and the Vega VideoPlayer component.
  • Create the VideoPlaybackScreen component which returns a placeholder text element wrapped in a View.
  • Export the VideoPlaybackScreen.
  • Create a StyleSheet called styles after the VideoPlaybackScreen arrow function.
  • Add a style called playerContainer and playerPlaceholder and assign the style props to the View and Text resectively.

Exiting the VideoPlaybackScreen

We need to provide a way to get back to the LandingScreen from the VideoPlaybackScreen. In reality, a customer will be able to use the “back” button on their remote to go back (or go “up” on the D-Pad and then choose to go back). However for now, we will create a basic “Back” button on-screen.
  • Add a View that contains a Button called “Back”
  • Set the Button’s onPress prop to be an arrow function that calls navigation.goBack().
  • Give the View a style prop of buttonContainer
  • Add the buttonContainer to the StyleSheet with the following values:

Export VideoPlaybackScreen

  • Dont forget to export the VideoPlaybackScreen in the index.ts
The VideoPlaybackScreen.tsx code should look like this:
最后修改于 2026年10月30日