apivideo / api.video-reactnative-player

React Native video player
https://api.video
MIT License
17 stars 2 forks source link

[Feat]: Allowing generic HLS video URL to play #15

Closed tinkalgogoi closed 1 year ago

tinkalgogoi commented 1 year ago

Version

v1.0.1

Environment that reproduces the issue

Device: OnePlus 8 PRO, OS: Android 12

Use case description

Right now we can play video only with videoID. But the generic video can't be played.

Proposed solution

Allow to play generic HLS url instead of only playing by videoID. We can use the playerUrl of ApiVideoPlayer

import {Button, View} from "react-native";
import ApiVideoPlayer from "@api.video/react-native-player";
import * as React from "react";

const PlayHLSStream = (props: any) => {
    const player = React.useRef(undefined as ApiVideoPlayer);

    return (
        <View style={{ flex: 1 }}>
            <ApiVideoPlayer
                ref={(r) => (player.current = r)}
                muted={true}
                videoId="vi2G6Qr8ZVE67dWLNymk7qbc"
            />

            <Button
                onPress={() => {
                    player.current.playerUrl = "http://192.168.221.15:7002/live/abcd.m3u8"
                    player.current.play() }
                }
                title="Play"
            />
            <Button onPress={() => player.current.pause()} title="Pause" />
        </View>
    )
}

export default PlayHLSStream;

Alternative solutions

No response

olivierapivideo commented 1 year ago

Hi @tinkalgogoi,

We have not planned that for now. If we decide to do so in the future, we will let you know.

Regards