从expo-video-player获取“ setAudioModeAsync错误”

时间:2019-07-09 23:38:04

标签: javascript react-native react-native-android expo

我尝试从我的手机上将视频加载到VideoPlayer上,即使完全不使用音频,也会因音频而出现一些错误。我正在使用的只是来自“ expo-av”的视频。 这是错误:

Error:, setAudioModeAsync error, 1, [Error: Audio mode attempted to be set without the required keys: ["staysActiveInBackground"]] Below is the code.

谢谢您的帮助!

import React, { Component } from 'react';
import { View, Text, StyleSheet, Button, TouchableOpacity } from 'react- 
native';
import {Video} from "expo";
import VideoPlayer from "expo-video-player";

export default class App extends Component {
render() {
// return <AppContainer />;
return(
    <View>
      <VideoPlayer
          videoProps={{
            shouldPlay: true,
            isLooping: true,
            resizeMode: Video.RESIZE_MODE_CONTAIN,
            source: {
              uri: 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
            },
          }}
          isPortrait={true}
          playFromPositionMillis={0}
      />

    </View>
);
}}

1 个答案:

答案 0 :(得分:0)

此问题是由Expo SDK 33创建的,其中一些模块已从核心中删除。

升级到最新版本(1.3.0)。它在这里固定。

https://www.npmjs.com/package/expo-video-player

重复的问题:https://stackoverflow.com/questions/56827764/problem-with-expo-video-player-it-throws-error-setaudiomodeasync