Skip to content

Commit

Permalink
add vlc settings, handle network-cacching for media separately
Browse files Browse the repository at this point in the history
  • Loading branch information
autoandshare committed May 11, 2021
1 parent f12cc83 commit 5c210f6
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 5 deletions.
19 changes: 16 additions & 3 deletions src/main/java/autoandshare/headvr/activity/SettingFragment.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package autoandshare.headvr.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
Expand Down Expand Up @@ -40,6 +41,8 @@ public void onActivityCreated(Bundle savedInstanceState) {
Button button = view.findViewById(R.id.buttonReset);
button.setOnClickListener(this);

view.findViewById(R.id.buttonVLCSettings).setOnClickListener(this);

initUI();
}

Expand Down Expand Up @@ -153,8 +156,18 @@ public void onStopTrackingTouch(SeekBar seekBar) {

@Override
public void onClick(View view) {
// reset values
setting.clear();
initUI();
if (view.getId() == R.id.buttonReset) {
// reset values
setting.clear();
initUI();
}
if (view.getId() == R.id.buttonVLCSettings) {
try {
startActivity(new Intent(this.getContext(),
Class.forName("org.videolan.vlc.gui.preferences.PreferencesActivity")));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
}
16 changes: 16 additions & 0 deletions src/main/java/autoandshare/headvr/lib/VideoRenderer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package autoandshare.headvr.lib;

import android.app.Activity;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.ParcelFileDescriptor;
import android.util.Log;
Expand All @@ -16,6 +17,8 @@
import org.videolan.libvlc.interfaces.IVLCVout;
import org.videolan.medialibrary.interfaces.media.MediaWrapper;
import org.videolan.resources.VLCInstance;
import org.videolan.resources.VLCOptions;
import org.videolan.tools.Settings;

import java.text.MessageFormat;

Expand Down Expand Up @@ -362,7 +365,20 @@ private IMedia getiMedia(MediaWrapper mw) {
return m;
}

private void setNetworkCaching(IMedia m) {
SharedPreferences vlcPrefs = Settings.INSTANCE.getInstance(activity.getApplicationContext());
int networkCaching = vlcPrefs.getInt("network_caching_value", 0);
if (networkCaching > 0) {
m.addOption(":network-caching=" + networkCaching);
}

}
private void playMedia(IMedia m) {
VLCOptions.INSTANCE.setMediaOptions(m, activity,
MediaWrapper.MEDIA_VIDEO, false);

setNetworkCaching(m);

// disable subtitle
m.addOption(MessageFormat.format(":sub-track-id={0}", String.valueOf(Integer.MAX_VALUE)));

Expand Down
27 changes: 25 additions & 2 deletions src/main/res/layout/setting_ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,26 @@

<View
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="@android:color/darker_gray" />

<Button
android:id="@+id/buttonVLCSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:text="VLC Settings" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp"
android:background="@android:color/darker_gray" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_margin="10dp" />

<TextView
Expand Down Expand Up @@ -159,8 +178,12 @@
android:id="@+id/buttonReset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp"
android:layout_margin="10dp"
android:text="Reset" />

<Space
android:layout_width="match_parent"
android:layout_height="100dp"/>

</LinearLayout>
</ScrollView>

0 comments on commit 5c210f6

Please sign in to comment.