TV应用亚马逊功能验证失败,因为在FireTV Stick #520的睡眠模式中播放视频。

huangapple go评论74阅读模式
英文:

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- 媒体:从休眠模式(系统待机模式)返回应用程序会导致不一致的行为,从而导致用户体验不佳 - 遥控器和游戏手柄

重现步骤:

  1. 安装并启动应用程序
  2. 播放任何视频
  3. 长按Home按钮以调用HUD(Heads UP Display)叠加
  4. 选择"Sleep"以将设备置于休眠模式
  5. 选择任何按钮以退出休眠模式并重新启动应用程序

实际结果:观察到应用程序音频在后台继续播放
期望结果:从休眠模式返回不应导致应用程序的不一致行为

我使用了以下版本的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 Gamepad

    Steps to reproduce:

    1. Install and launch the app
    2. Play any video
    3. Long press Home button to invoke HUD (Heads UP Display) overlay
    4. Select Sleep to put the device to Sleep mode
    5. 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.

&quot;react-native&quot;: &quot;npm:react-native-tvos@0.69.8-1&quot;,
&quot;react-native-video&quot;: &quot;^5.2.1&quot;

here is my code for video component.

      &lt;Video
        ref={setPlayer}
        subtitle={true}
        source={{
          uri: configuration.url,
        }}
        title={title}
        subTitleText={subtitle}
        style={[styles.playerLoaded]}
        paused={pausedRef.current}
        onLoad={handleLoad}
        resizeMode={&#39;contain&#39;}
        rate={playerRate}
        onProgress={handleProgress}
        onError={onError}
        onLoadStart={onLoadStart}
        onSeek={handleSeek}
        onReadyForDisplay={onReadyForDisplay}
        onEnd={onEndVideo}
        playInBackground={false}
        playWhenInactive={false}
      /&gt;

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 &quot;react&quot;;
    import { AppState, Text, View } from &quot;react-native&quot;;
        
    const AppInactiveHandleExample = () =&gt; {
        const appState = useRef(AppState.currentState);
        const [appStateVisible, setAppStateVisible] = useState(appState.current);
    
        useEffect(() =&gt; {
            AppState.addEventListener(&quot;change&quot;, handleAppStateChange);
            // Return for clear the cache of action
            return () =&gt; {
                AppState.removeEventListener(&quot;change&quot;, handleAppStateChange);
            };
        }, []);
    
        const handleAppStateChange = nextAppState =&gt; {
        if (
            appState.current.match(/inactive|background/) &amp;&amp;
            nextAppState === &quot;active&quot;
        ) {
            // Resume the Video/Audio
            onAppInactive()
        }
            appState.current = nextAppState;
            setAppStateVisible(appState.current);
        };
    
        // Action executed when app was inactive or background
        const onAppInactive = () =&gt; {
            // Pause the Video/Audio
        }
    
        return (
        &lt;View&gt;
            &lt;Text&gt;Current state is: {appStateVisible}&lt;/Text&gt;
        &lt;/View&gt;
        );
    };
    
    export default AppInactiveHandleExample;

huangapple
  • 本文由 发表于 2023年6月12日 17:01:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76455068.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定