React-native-video: how to play a video and a sound or two sound files at the same time by react native

Created on 16 Jan 2019  路  3Comments  路  Source: react-native-video/react-native-video

how to play a video and a sound or two sound files at the same time by react native on ios and android

Most helpful comment

@wang777777 Have you tried multiple instances of react-native-video and maybe react-native-sound? It should be capable of handling them. If not, we've written our own multi-track AV player internally which we're considering open sourcing if there's enough demand.

All 3 comments

@wang777777 Have you tried multiple instances of react-native-video and maybe react-native-sound? It should be capable of handling them. If not, we've written our own multi-track AV player internally which we're considering open sourcing if there's enough demand.

@JofBigHealth It is an indispensable feature for me. How would you assess if there is enough demand? I can try to let other developers know so that they give more upvotes on the comment.

@johnyoonh I don't think we're going to open source it in the end. If sub 150ms latency is required, the code for the native multiplexer for Android is quite complex requiring custom synchronisation logic and custom own codec implementations. Maybe 2-3000LOC of Java and C. And even then it's not perfect. Meanwhile, iOS is just 150LOC. Such a shame Android is poor at media... :/

For now what we have is a slight modification of react-native-video that supports imperative play/pause calls across all platforms (including web) such that we can run multiple RNV players by using callbacks across the bridge (and not React state changes which is very poor performance because it requires re-render) to sync their native play/pause methods. This works pretty well in fact and provided you are ok with the latency will work for you just fine too.

Unfortunately I'm super busy right now and have a long list of OSS stuff I've been meaning to do, but we do have a ticket on Jira to raise a PR against RNV to introduce the imperative API. With that, you'll be able to do what you need. It's actually not much code at all so someone else may be able to pick it up in my stead.

Was this page helpful?
0 / 5 - 0 ratings