英文:
TV App Amazon functionality validation fail due to video play in background in sleep mode in FireTV stick #520
问题
我已将我的React Native TVOS应用程序提交到Amazon商店,但他们给出了以下功能验证错误。
- FireTV-24- 媒体:从休眠模式(系统待机模式)返回应用程序会导致不一致的行为,从而导致用户体验不佳 - 遥控器和游戏手柄
重现步骤:
- 安装并启动应用程序
- 播放任何视频
- 长按Home按钮以调用HUD(Heads UP Display)叠加
- 选择"Sleep"以将设备置于休眠模式
- 选择任何按钮以退出休眠模式并重新启动应用程序
实际结果:观察到应用程序音频在后台继续播放
期望结果:从休眠模式返回不应导致应用程序的不一致行为
我使用了以下版本的TVOS和React Native Video。
"react-native": "npm:react-native-tvos@0.69.8-1",
"react-native-video": "^5.2.1"
这是我的视频组件的代码。
<Video
ref={setPlayer}
subtitle={true}
source={{
uri: configuration.url,
}}
title={title}
subTitleText={subtitle}
style={[styles.playerLoaded]}
paused={pausedRef.current}
onLoad={handleLoad}
resizeMode={'contain'}
rate={playerRate}
onProgress={handleProgress}
onError={onError}
onLoadStart={onLoadStart}
onSeek={handleSeek}
onReadyForDisplay={onReadyForDisplay}
onEnd={onEndVideo}
playInBackground={false}
playWhenInactive={false}
/>
请帮助我解决这个问题。
提前谢谢您。
英文:
I have submitted my react-native-tvos app to the Amazon store but they give below a functionality validation error.
-
FireTV-24- Media: Returning to the app from Sleep (System Standby)
mode causes inconsistent behavior resulting in a negative user
experience - Remote and GamepadSteps to reproduce:
- Install and launch the app
- Play any video
- Long press Home button to invoke HUD (Heads UP Display) overlay
- Select Sleep to put the device to Sleep mode
- Select any button to come out of sleep mode and relaunch the app Actual Result: observe that app audio continues to play in background
Expected Result: Returning back from sleep mode should not result in inconsistent behavior of the app
I have used below version of tvos and React native video.
"react-native": "npm:react-native-tvos@0.69.8-1",
"react-native-video": "^5.2.1"
here is my code for video component.
<Video
ref={setPlayer}
subtitle={true}
source={{
uri: configuration.url,
}}
title={title}
subTitleText={subtitle}
style={[styles.playerLoaded]}
paused={pausedRef.current}
onLoad={handleLoad}
resizeMode={'contain'}
rate={playerRate}
onProgress={handleProgress}
onError={onError}
onLoadStart={onLoadStart}
onSeek={handleSeek}
onReadyForDisplay={onReadyForDisplay}
onEnd={onEndVideo}
playInBackground={false}
playWhenInactive={false}
/>
here i attached screenshot of error given by amazon.
please help me to fix this issue.
Thank you in advance.
答案1
得分: 0
以下是您要翻译的内容:
"这可能是该组件特定版本中的一个错误。无论如何,您可以使用AppState在应用程序进入后台时执行操作。
示例:"
import React, { useRef, useState, useEffect } from "react";
import { AppState, Text, View } from "react-native";
const AppInactiveHandleExample = () => {
const appState = useRef(AppState.currentState);
const [appStateVisible, setAppStateVisible] = useState(appState.current);
useEffect(() => {
AppState.addEventListener("change", handleAppStateChange);
// Return for clear the cache of action
return () => {
AppState.removeEventListener("change", handleAppStateChange);
};
}, []);
const handleAppStateChange = nextAppState => {
if (
appState.current.match(/inactive|background/) &&
nextAppState === "active"
) {
// 恢复视频/音频
onAppInactive()
}
appState.current = nextAppState;
setAppStateVisible(appState.current);
};
// 应用程序不活动或后台时执行的操作
const onAppInactive = () => {
// 暂停视频/音频
}
return (
<View>
<Text>当前状态是:{appStateVisible}</Text>
</View>
);
};
export default AppInactiveHandleExample;
英文:
It could be a bug in that specific version of the component.
Anyway you can use the AppState to perform an action every time the app goes in background
Example:
import React, { useRef, useState, useEffect } from "react";
import { AppState, Text, View } from "react-native";
const AppInactiveHandleExample = () => {
const appState = useRef(AppState.currentState);
const [appStateVisible, setAppStateVisible] = useState(appState.current);
useEffect(() => {
AppState.addEventListener("change", handleAppStateChange);
// Return for clear the cache of action
return () => {
AppState.removeEventListener("change", handleAppStateChange);
};
}, []);
const handleAppStateChange = nextAppState => {
if (
appState.current.match(/inactive|background/) &&
nextAppState === "active"
) {
// Resume the Video/Audio
onAppInactive()
}
appState.current = nextAppState;
setAppStateVisible(appState.current);
};
// Action executed when app was inactive or background
const onAppInactive = () => {
// Pause the Video/Audio
}
return (
<View>
<Text>Current state is: {appStateVisible}</Text>
</View>
);
};
export default AppInactiveHandleExample;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论