i want to play a music at background of my app using react-native expo. so i used expo-av components.
after running the app, music plays correctly but after while,unreasonable its stops playing just before the music ends!!
Note: after running program, i receive this Warning message:
Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground.
here is my codes:
import React, { Component } from 'react'
import { Audio } from 'expo-av'
handlePlaySound = async fileAdd => {
const soundObj = new Audio.Sound();
try{
await soundObj.loadAsync(fielAdd);
await soundObj.playAsync;
}catch(error){
console.log(error);
}
}
export default function HomeScreen() {
let source = require('./assets/sounds/bg.mp3');
this.handlePlaySound(source);
return (.....Ui Components
);
}