itsnubix / react-native-video-controls

A React Native video component with controls
MIT License
637 stars 526 forks source link

check the render method of 'VideoPlayer' #91

Closed CoderSwitch closed 6 years ago

CoderSwitch commented 6 years ago

If the network link address is passed into the VideoPlayer component, it will crash. What is the reason for this? The code is consistent with the author?

CoderSwitch commented 6 years ago

78169b8fccec438b3452a1f8e7229723

kylemilloy commented 6 years ago

Can you post your full code? I would start with consoling out the props you're passing the VideoPlayer. I would assume you're accidentally passing an undefined prop to it. Perhaps _this.videoUrl.

kylemilloy commented 6 years ago

Any updates here?

CoderSwitch commented 6 years ago

1522824424064 1522824504884 Sorry, there's no real time update, so these two graphs are all code, and it's weird that the program just doesn't recognize this VideoPlayer.

CoderSwitch commented 6 years ago

ExhibitWorks.js.zip

kylemilloy commented 6 years ago

+1 for screenshots and including your code here...lemme take a look and see if I can figure it out...

kylemilloy commented 6 years ago

Alright....so...here's my findings.

I can't get _this.videoUrl to return anything as it's calling for FILEHOST and HOST that I'm assuming are globals you've setup. However when I test the url that you put the test video you're using (http://techslides.com/demos/sample-videos/small.mp4) it errors on iOS because it's not HTTPS. Unrelated, but just an FYI.

Are you developing for Android or Apple? Can you show me your package.json file as well?

I notice that you're importing some custom components that you made yourself. If you remove these components do you still encounter issues? Are you exporting them as the default component within their own files? What I mean is that in the Login, Loading and ExpertExam components do you have the following:

export default class Login {}

// or 

class Login {}
export default Login;

// instead of 

export class Login {}
// etc.

If not you'll need to add curly brackets around your import statements or add the default keyword:

import {Login} from './Login';

If I remove the references to your custom components, remove the axios calls, remove calls to HOST/FILEHOST, set a height/width in the render method and then bybass your this.state.isPlayVideo if gate I can get the VideoPlayer to load, which leads me to suspect that the issue is something higher up the chain.

screen shot 2018-04-04 at 9 35 27 am

Does this help?

kylemilloy commented 6 years ago

Any luck?

CoderSwitch commented 6 years ago

Thank you for your help and serious solution. I am iOS development. I will try your answer and reply to you later.

CoderSwitch commented 6 years ago

I tried the solution you said, but it still doesn't work.

CoderSwitch commented 6 years ago

package.json.zip

kylemilloy commented 6 years ago

Ahhh...you're using RN version <45...hmmm...lemme look into it some more here...

kylemilloy commented 6 years ago

Alright...I think I know what's up...this is a guess however as I am unable to test back previous versions of react-native so I'll have to rely on you testing this for me.

So you're likely using v1.5.1 of react-native-video-controls which includes a change to how background images were used starting in react-native v46+. That said, you're using react-native v44 alpha release which doesn't have this update so you're likely encountering the error. (you can see this update here)

So the root problem is my documentation sucks...I'm advising people to use v.1.x for RN <46 and that's just not right. They should be using v.1.3 or lower, that's when my I udpated the peer dependencies from RN 42 to >= RN 46. I've updated the packages documentation to reflect this.

So to fix your problem let's try updating your package.json. If you could, downgrade react-native-video to ^1.0.0 and react-native-video-controls to ~1.3.1. First, unlink react-native-video. Once you've done that and made the change in package.json to get the new packages then run npm update or yarn upgrade to pull in the new packages. Relink react-native-video. Try that again.

Package.json should look like this:

{
  "dependencies": {
    // ...
    "react-native-video": "^1.0.0",
    "react-native-video-controls": "~1.3.1"
    // ...
  }
}

Be sure to hardcode react-native-video-controls 1.3.1 or use a tilde and not a caret.

CoderSwitch commented 6 years ago

According to your solution successfully run, thank you very much for your help, because this project is relatively old, also not developed by themselves, I am still a novice, so I am at a loss, really thank you for your help, thank you again

CoderSwitch commented 6 years ago

You can turn it off when you check my reply, or I'll shut it down tomorrow. Thank you again for your help and careful answers.

kylemilloy commented 6 years ago

Glad it worked. :)