Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Error: Expected URL scheme 'http' or 'https' but was 'file' #103

Open
linus opened this issue Oct 14, 2019 · 2 comments · May be fixed by #228
Open

Error: Expected URL scheme 'http' or 'https' but was 'file' #103

linus opened this issue Oct 14, 2019 · 2 comments · May be fixed by #228

Comments

@linus
Copy link

linus commented Oct 14, 2019

I'm trying to use expo-pixi to read out the color of the background (really the top left pixel) of an image. The image is hosted on a https:// url.

I'm doing this:

  async getBackgroundColor(imageUri) {
    const context = await GLView.createContextAsync()
    const app = new PIXI.Application({ context })
    console.log('[PIXI] loading', imageUri)
    const sprite = await PIXI.Sprite.fromExpoAsync(imageUri)
    console.log('[PIXI] sprite', sprite)
    app.stage.addChild(sprite)
    const pixels = app.renderer.extract.pixels(sprite)
    console.log('[PIXI] extracted pixels', pixels.length)
    const [r, g, b, a] = pixels.slice(0, 4)
    console.log('[PIXI] loaded pixels', [r, g, b, a])

    return `rgba(${r}, ${g}, ${b}, ${a})`
  }

Unfortunately, the call PIXI.Sprite.fromExpoAsync(imageUri) throws an error:

Error: Expected URL scheme 'http' or 'https' but was 'file'

I have looked through the documentation as well as reading through the issues and some of the code, it seems as if the exception comes from a lower level, but how is fromExpoAsync supposed to be used? Is it possible to use remote resources? Should I use another API?

See this snack: https://snack.expo.io/@fredrikschweinebarth/8ac094

@linus
Copy link
Author

linus commented Oct 14, 2019

It seems as if this is because of a bug in expo-asset-utils: expo/expo-asset-utils#18

@LeonYuanYao
Copy link

LeonYuanYao commented Feb 26, 2020

Have you managed to solve this problem? I had the same issue when loading a texture from remote url.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants