Audio expo-av file is not loaded on iOS

Hi,

I’m following your playlist GitHub - expo/playlist-example. But I keep getting {isLoaded:false} on iOS.

This is what I have,

const source = { uri: url };
const { sound, status } = await Audio.Sound.createAsync(
      source,
      initialStatus,
      _onPlaybackStatusUpdate
    );

This works perfectly when I’m using the URL from the example, but it stop working with my own file hosting on Digital Ocean Spaces. https://pollycast.sfo2.digitaloceanspaces.com/production/1572290707872|9288520562.mp3

Can you take a look at it and let me know why?
Thanks very much :smiley:

Hey @montekaka,

Can you share the code you’ve implemented where it does not work with your DO mp3 url?

Cheers,
Adam

1 Like

Sure!
Here is what I have. Thanks so much for your looking into it :smiley:

import createDataContext from './createDataContext';
import { Audio, Video } from "expo-av";

const LOOPING_TYPE_ALL = 0;
const LOADING_STRING = "... loading ...";
const BUFFERING_STRING = "...buffering...";

const initialStatus = {
  shouldPlay: true,
  rate: 1.0,
  shouldCorrectPitch: true,
  volume: 1.0,
  isMuted: false,
  isLooping: false
};

const _onPlaybackStatusUpdate = (status) => {
  console.log(status)
}

const reducer = (state, action) => {
  switch (action.type) {
    case 'play':
      return {...state, ...action.payload};    
    default:
      return state;
  }
}

const play = (dispatch) => async(url) => {

  const source = { uri: url };
  try {
    console.log(source)
    const { sound, status } = await Audio.Sound.createAsync(
      source,
      initialStatus,
      _onPlaybackStatusUpdate
    );
    
    //sound.playAsync();
    dispatch({type: 'play', payload: {playbackInstance: sound}})
  } catch (err) {
    console.log('error...')
    console.log(err);
  }
}

export const {Provider, Context} = createDataContext(
  reducer,
  { play },
  {
    showVideo: false,
    playbackInstanceName: LOADING_STRING,
    loopingType: LOOPING_TYPE_ALL,
    muted: false,
    playbackInstancePosition: null,
    playbackInstanceDuration: null,
    shouldPlay: false,
    isPlaying: false,
    isBuffering: false,
    isLoading: true,
    fontLoaded: false,
    shouldCorrectPitch: true,
    volume: 1.0,
    rate: 1.0,
    poster: false,
    useNativeControls: false,
    fullscreen: false,
    throughEarpiece: false,
    playbackInstance: null
  }
)

FIXED looks like the createAsync only accepting an encoded URL

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.