doublesymmetry / react-native-track-player

A fully fledged audio module created for music apps. Provides audio playback, external media controls, background mode and more!
https://rntp.dev/
Apache License 2.0
3.25k stars 1k forks source link

App crashed in android when type selected hls or smoothstreaming #1043

Closed gulsher7 closed 3 years ago

gulsher7 commented 3 years ago

Run react-native info in your project and share the content. System: OS: macOS 10.15 CPU: (4) x64 Intel(R) Core(TM) i5-4570T CPU @ 2.90GHz Memory: 462.33 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 14.4.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.8 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.0. - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 23, 25, 26, 27, 28, 29 Build Tools: 27.0.3, 28.0.3, 29.0.2, 29.0.3, 30.0.0, 30.0.0, 30.0.1, 30.0.2 Android NDK: Not Found IDEs: Android Studio: 4.0 AI-193.6911.18.40.6626763 Xcode: 11.3/11C29 - /usr/bin/xcodebuild Languages: Java: 1.8.0_252 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.3 => 0.63.3 What react-native-track-player version are you using? = 1.2.3

Are you testing on a real device or in the simulator? Which OS version are you running? yes i tested on xiomi redmi note 7 pro real device and its version 10

Code Please, share the code that is causing the issue import React, { useState, useEffect } from 'react'; import TrackPlayer, { useTrackPlayerProgress } from 'react-native-track-player'; import ProgressSlider from '../../components/ProgressSlider';

const AudioPlayer = ({ route }) => {

const [isPlaying, setPlaying] = useState(false)
const song = route.params.song

 useEffect(() => {
    (async () => {
        try {
            await TrackPlayer.reset()
            await TrackPlayer.add({
                id: song?.id,
                url: 'https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8',
                title: song?.a_name || 'unknown',
                artist: 'Syncro',
                artwork: "https://images.unsplash.com/photo-1595971348132-009effb2a9b3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80",
                type: 'hls'
            });
        } catch (error) {
            console.log(error)
        }
    })();
}, []);

const setPlayPause = (isPlaying) => {
    console.log("is palying action", isPlaying)
    { isPlaying ? TrackPlayer.play() : TrackPlayer.pause() }
    setPlaying(isPlaying)
};
puckey commented 3 years ago

Could you add a crash log / stacktrace?

bang9 commented 3 years ago

Did you add track-player.json file to root of your project?

Nitish157 commented 3 years ago

Yes but nothing working in tihs

maxckelly commented 3 years ago

I fixed the hls crash by adding the file type. However the audio isn't playing from the emulator. Unsure if this is an emulator thing or or a hls thing.

masarbazi commented 2 years ago

Problem still on going. tried setting contentType but didn't work. Setting type to smoothstreaming, hls and app crashes.

dcvz commented 2 years ago

Did you also make sure to enable the relevant module? http://react-native-track-player.js.org/build-preferences/

masarbazi commented 2 years ago

Thx David. It was my stupid mistake I had named track-player.json as track-player.js, LOL :)