Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@ Copy Ionicons.ttf from `node_modules/react-native-vector-icons/Fonts` to `androi

#### Android

1. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
1. Insert the following lines inside the repositories block in `android/build.gradle`:
```Diff
...
allprojects {
...
dependencies {
...
+ maven {
+ url("https://jitpack.io")
+ }
}
repositories {
...
maven { url("https://jitpack.io") }
...
}
}
```

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ repositories {

dependencies {
implementation "com.facebook.react:react-native:${safeExtGet('reactnativeVersion', '+')}"
implementation 'de.mrmaffen:vlc-android-sdk:1.9.8'
implementation 'de.mrmaffen:libvlc-android:2.1.12'
}

def configureReactNativePom(def pom) {
Expand Down
33 changes: 9 additions & 24 deletions android/src/main/java/com/ghondar/vlc/VlcPlayerView.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public String toString() {
private static final int SURFACE_4_3 = 5;
private static final int SURFACE_ORIGINAL = 6;

private int mCurrentSize = SURFACE_BEST_FIT;
private int mCurrentSize = SURFACE_FILL;
private Media media;
private boolean autoPlay;

Expand All @@ -114,28 +114,8 @@ private void initializePlayerIfNeeded() {
final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getContext().getApplicationContext());
// Create LibVLC
ArrayList<String> options = new ArrayList<>(50);
int deblocking = getDeblocking(-1);

int networkCaching = pref.getInt("network_caching_value", 0);
if (networkCaching > 60000) networkCaching = 60000;
else if (networkCaching < 0) networkCaching = 0;
options.add("--audio-time-stretch");
options.add("--avcodec-skiploopfilter");
options.add("" + deblocking);
options.add("--avcodec-skip-frame");
options.add("0");
options.add("--avcodec-skip-idct");
options.add("0");
options.add("--subsdec-encoding");
options.add("--stats");
if (networkCaching > 0) options.add("--network-caching=" + networkCaching);
options.add("--androidwindow-chroma");
options.add("RV32");

options.add("-vv");

libvlc = new LibVLC(options);

libvlc = new LibVLC(getContext().getApplicationContext(), options);
holder.setKeepScreenOn(true);

// Create media player
Expand All @@ -156,6 +136,12 @@ private void setMedia(String filePath) {
}
Uri uri = Uri.parse(filePath);
media = new Media(libvlc, uri);
int cache = 150;
media.addOption(":network-caching=" + cache);
media.addOption(":file-caching=" + cache);
media.addOption(":live-cacheing=" + cache);
media.addOption(":sout-mux-caching=" + cache);
media.addOption(":codec=mediacodec,iomx,all");
mMediaPlayer.setMedia(media);
if (autoPlay) {
mMediaPlayer.play();
Expand Down Expand Up @@ -270,6 +256,7 @@ private void changeSurfaceSize(int width, int height) {
break;
}


// set display size
int finalWidth = (int) Math.ceil(displayWidth * mVideoWidth / mVideoVisibleWidth);
int finalHeight = (int) Math.ceil(displayHeight * mVideoHeight / mVideoVisibleHeight);
Expand Down Expand Up @@ -329,7 +316,6 @@ public void setVolume(int volume) {
mMediaPlayer.setVolume(volume);
}

@Override
public void onNewLayout(IVLCVout vout, int width, int height, int visibleWidth, int visibleHeight, int sarNum, int sarDen) {
if (width * height == 0) return;

Expand All @@ -349,7 +335,6 @@ public void onSurfacesDestroyed(IVLCVout vout) {

}

@Override
public void onHardwareAccelerationError(IVLCVout vout) {
// Handle errors with hardware acceleration
this.releasePlayer();
Expand Down