Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android support #103

Merged
merged 28 commits into from
Dec 12, 2015
Merged

Android support #103

merged 28 commits into from
Dec 12, 2015

Conversation

isair
Copy link
Contributor

@isair isair commented Nov 2, 2015

  • Add Android support.
  • Update README.
  • Update example project.

Closes #91, fixes #94.

Review on Reviewable

@jforaker
Copy link

@isair could you provide a gist or readme on installation instructions? I recognize the risk on my end, but i would be eternally grateful as time is of the essence and i really need this :)

@isair
Copy link
Contributor Author

isair commented Nov 14, 2015

@jforaker You need to make additions to 3 files in your react-native project.

android/settings.gradle

include ':RCTVideo', ':app'
project(':RCTVideo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android')

android/app/build.gradle

dependencies {
   ...
   compile project(':RCTVideo')
}

MainActivity.java

On top, where imports are:

import com.brentvatne.react.ReactVideoPackage;

Under .addPackage(new MainReactPackage()):

.addPackage(new ReactVideoPackage())

@jforaker
Copy link

Thanks!

Howerver, I think you forgot ReactVideoView in your package.json. I fixed that, however i get red death screen error on run:

Requiring unknown module "keymirror"

I did npm install keymirror and that did not help. Ideas?

@jforaker
Copy link

@isair After testing a few times, few different configs, the video does not play, and i keep getting this error in Android Studio (no errors in chrome):

11-16 19:53:44.255 2415-2415/com.crashr_react_native W/ResourceType: No package identifier when getting value for resource number 0x00000000
11-16 19:53:44.255 2415-2415/com.crashr_react_native W/System.err: android.content.res.Resources$NotFoundException: Resource ID #0x0
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at android.content.res.Resources.getValue(Resources.java:1266)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at android.content.res.Resources.openRawResourceFd(Resources.java:1224)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.yqritc.scalablevideoview.ScalableVideoView.setRawData(ScalableVideoView.java:121)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.brentvatne.react.ReactVideoView.setSrc(ReactVideoView.java:119)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.brentvatne.react.ReactVideoViewManager.setSrc(ReactVideoViewManager.java:66)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at java.lang.reflect.Method.invoke(Method.java:372)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.facebook.react.uimanager.ViewManagersPropertyCache$MapPropSetter.updateProperty(ViewManagersPropertyCache.java:175)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.facebook.react.uimanager.ViewManagersPropertyCache$PropSetter.updateProp(ViewManagersPropertyCache.java:63)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.facebook.react.uimanager.ViewManager.updateProperties(ViewManager.java:47)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.facebook.react.uimanager.NativeViewHierarchyManager.createView(NativeViewHierarchyManager.java:182)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.facebook.react.uimanager.UIViewOperationQueue$CreateViewOperation.execute(UIViewOperationQueue.java:137)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:574)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:622)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.facebook.react.uimanager.GuardedChoreographerFrameCallback.doFrame(GuardedChoreographerFrameCallback.java:32)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.facebook.react.uimanager.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:114)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:765)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at android.view.Choreographer.doCallbacks(Choreographer.java:580)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at android.view.Choreographer.doFrame(Choreographer.java:549)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at android.os.Handler.handleCallback(Handler.java:739)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at android.os.Looper.loop(Looper.java:135)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5254)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at java.lang.reflect.Method.invoke(Method.java:372)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
11-16 19:53:44.259 2415-2415/com.crashr_react_native W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

I have the "broadchurch.mp4" in the same directory as my video component, calling it like this:

    <Video source={{uri: 'broadchurch'}}
           style={styles.fullScreen}
           rate={this.state.rate}
           paused={this.state.paused}
           volume={this.state.volume}
           muted={this.state.muted}
           resizeMode={this.state.resizeMode}
           onLoad={this.onLoad}
           onProgress={this.onProgress}
           repeat={false}/>

Does it work for you? Am I setting the source incorrectly? (tried new source={require('./my-icon.png')} style syntax and that threw a red screen error)

@isair
Copy link
Contributor Author

isair commented Nov 17, 2015

@jforaker Try putting your video file in your Android raw sources folder.

@jforaker
Copy link

Ok I tried all of these:
<Video source={{uri: './android/app/src/main/assets/broadchurch'}}
<Video source={{uri: './android/app/src/main/assets/broadchurch.mp4'}}
<Video source={{uri: 'android/app/src/main/assets/broadchurch'}}
<Video source={{uri: 'android/app/src/main/assets/broadchurch.mp4'}}

and get the same error

11-16 20:58:03.066 21349-21349/com.crashr_react_native W/System.err: android.content.res.Resources$NotFoundException: Resource ID #0x0

Also tried a youtube source and get this:

11-16 20:53:26.010 19736-19736/com.crashr_react_native W/MediaPlayer: setScreenOnWhilePlaying(true) is ineffective without a SurfaceHolder
11-16 20:53:26.024 2551-15396/? D/NuPlayerDriver: reset(0xf10cfae0)
11-16 20:53:26.024 2551-15396/? D/NuPlayerDriver: notifyListener_l(0xf10cfae0), (1, 0, 0)
11-16 20:53:26.024 2551-15396/? D/NuPlayerDriver: notifyListener_l(0xf10cfae0), (8, 0, 0)
11-16 20:53:26.024 2551-20102/? D/NuPlayerDriver: notifyResetComplete(0xf10cfae0)
11-16 20:53:26.025 2551-4928/? D/NuPlayerDriver: reset(0xf10cfae0)
11-16 20:53:26.041 19736-19736/com.crashr_react_native W/MediaPlayer: setScreenOnWhilePlaying(true) is ineffective for Surface
11-16 20:53:26.041 2551-20107/? D/NuPlayer: onSetVideoSurface(0xee403500, no video decoder)
11-16 20:53:26.990 2551-20126/? I/NuCachedSource2: caching reached eos.
11-16 20:53:27.003 2551-20127/? E/NuCachedSource2: source returned error -1, 10 retries left
11-16 20:53:27.027 2551-20108/? E/GenericSource: Failed to init from data source!
11-16 20:53:27.028 2551-20107/? D/NuPlayerDriver: notifyListener_l(0xf10d0260), (100, 1, -2147483648)
11-16 20:53:27.028 19736-20106/com.crashr_react_native E/MediaPlayer: error (1, -2147483648)
11-16 20:53:27.032 19736-19736/com.crashr_react_native E/MediaPlayer: Error (1,-2147483648)
11-16 20:53:28.865 3674-12188/? D/NetlinkSocketObserver: NeighborEvent{elapsedMs=539731960, 192.168.0.1, [407009528617], RTM_NEWNEIGH, NUD_STALE}
11-16 20:53:30.272 2551-20127/? I/NuCachedSource2: retrying a previously failed read succeeded.
11-16 20:53:30.276 2551-20127/? I/NuCachedSource2: caching reached eos.
11-16 20:53:30.282 2551-20103/? E/GenericSource: Failed to init from data source!
11-16 20:53:30.290 2551-20103/? W/AMessage: failed to post message as target looper for handler 0 is gone.

@isair
Copy link
Contributor Author

isair commented Nov 17, 2015

<Video source={{uri: 'broadchurch'}} /> is fine. Just put that mp4 file in android/app/src/main/res/raw/.

@jforaker
Copy link

BOOM goes the dynamite! There it is!! 👍 thank you

@jforaker
Copy link

Be sure to make a note in the install docs:

Error: 'G' is not a valid file-based resource name character: File-based resource names must contain only lowercase a-z, 0-9, or underscore
111

aka filename must only contain lowercase a-z, 0-9, or underscore

@isair
Copy link
Contributor Author

isair commented Nov 18, 2015

@jforaker Will keep in mind, cheers!

@isair
Copy link
Contributor Author

isair commented Nov 20, 2015

Reviewed 8 of 11 files at r1, 4 of 4 files at r2.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from the review on Reviewable.io

@brentvatne
Copy link
Contributor

😍

@jforaker
Copy link

jforaker commented Dec 6, 2015

@isair it seems to be broken in 0.16.0 (was working flawlessly in 0.15 and under). Possibly related to facebook/react-native#4605 < check it out

@brentvatne
Copy link
Contributor

@isair - this is working great so far! @jforaker - submitted a PR upstream to fix this. Also added the example project so I checked that off above. If you want to add the documentation above to the README (follow the steps verbatim and it worked without a hitch) I'm comfortable landing this now if you are!

@isair
Copy link
Contributor Author

isair commented Dec 7, 2015

@brentvatne Thanks for fixing that issue. I'll update the README and finalize this PR tonight.

@brentvatne
Copy link
Contributor

@jforaker - I would argue that @isair rocks more for his awesome work on this branch 🚀 🎸

@isair
Copy link
Contributor Author

isair commented Dec 8, 2015

Reviewed 26 of 32 files at r3, 1 of 1 files at r4, 2 of 8 files at r5.
Review status: all files reviewed at latest revision, all discussions resolved.


Comments from the review on Reviewable.io

@isair isair changed the title [WIP] Android support Android support Dec 8, 2015
@isair
Copy link
Contributor Author

isair commented Dec 8, 2015

@brentvatne Haha, my pleasure.

@rclai
Copy link

rclai commented Dec 9, 2015

Whoa, this looks awesome. Is this about to get merged today?

@eranbes
Copy link

eranbes commented Dec 11, 2015

Yes, merge merge merge :-)

@isair isair assigned isair and unassigned brentvatne Dec 12, 2015
isair added a commit that referenced this pull request Dec 12, 2015
@isair isair merged commit f4c3e14 into master Dec 12, 2015
@isair isair deleted the feature/android-support branch December 12, 2015 00:13
@ghost ghost mentioned this pull request Aug 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

onVideoError and onVideoLoadStart native properties are unset Android Support
5 participants