question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Video file does not play on Android release builds (when using require)

See original GitHub issue

Hello Team,

For the past few months, I’ve been trying to play an .mp4 video on the Video component from expo-av module but only succeeded on iOS.

It just does not load/play on Android.

I’m using the following modules on the bare workflow: “expo”: “36.0.0”, “expo-av”: “8.0.0”, “react”: “16.9.0”, “react-native”: “0.61.4”

And here is a snippet of my code:

import Videos from '../../assets/videos'

const Walkthrough = ({ navigation }) => (
	<Video
		isLooping
		isMuted
		shouldPlay
		key={3}
		resizeMode={Video.RESIZE_MODE_COVER}
		source={{ uri: Videos.Nv, overrideFileExtensionAndroid: 'mp4' }}
		style={[
			{
				bottom: 0,
				left: 0,
				position: 'absolute',
				right: 0,
				top: 0,
			},
		]}
	/>
)

The video does play on Emulator with debug mode but not in release mode.

Any idea on how I can resolve this issue ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:8
  • Comments:14 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
miversencommented, May 29, 2020

I found the solution that works on device and emulator after studying the Video and Audio classes a bit closer. I should note that I’m also using expo-asset 8.1.5.

This does NOT work for me, it’s not loading the video on android devices:

<Video source={require('video.mp4')} />

This DOES works for me:

<Video ref={this.handleVideoRef} />
handleVideoRef = async (component) => {
    if (component && !this.playbackObject) {
      this.playbackObject = component;
      await this.playbackObject.loadAsync(Asset.fromModule(require('video.mp4')));
      await this.playbackObject.playAsync();
    }
  }

And for Audio, it’s the same, so this does NOT work for me on android device:

const soundObject = new Audio.Sound();
await soundObject.loadAsync(require('sound.mp3'));
await soundObject.playAsync();

And this DOES works for me:

const soundObject = new Audio.Sound();
await soundObject.loadAsync(Asset.fromModule(require('sound.mp3')));
await soundObject.playAsync();
2reactions
mikeRChambers610commented, Oct 21, 2020

I got same, and solved by ref.

@watanabeyu Can you please provide detail or a code example rather than letting us know you solved it? thanks…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Embedded local video file not playing on Android
Embedded local video file not playing on Android in release build but fine in debug build when using AppBuilder (Windows Client).
Read more >
Supported media formats
This document describes the media codec, container, and network protocol support provided by the Android platform.
Read more >
Troubleshoot known issues with Android Emulator
This page lists known issues, workarounds, and troubleshooting tips for the Android Emulator. If you encounter an issue not listed here or ...
Read more >
Prepare your app for release
Learn how to build a signed, release-ready APK. This process is the same for all Android apps.
Read more >
Known issues with Android Studio and Android Gradle Plugin
If Studio doesn't start after an upgrade, the problem may be due to an invalid Android Studio configuration imported from a previous version...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found