Commit 4c059c13 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Add an option to change the encoding of the subtitles

parent e47d79e4
......@@ -412,6 +412,12 @@ void Java_org_videolan_vlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz, jboolean
methodId = (*env)->GetMethodID(env, cls, "timeStretchingEnabled", "()Z");
bool enable_time_stretch = (*env)->CallBooleanMethod(env, thiz, methodId);
methodId = (*env)->GetMethodID(env, cls, "getSubtitlesEncoding", "()Ljava/lang/String;");
jstring subsencoding = (*env)->CallObjectMethod(env, thiz, methodId);
const char *subsencodingstr = (*env)->GetStringUTFChars(env, subsencoding, 0);
LOGD("Subtitles encoding sets to: %s", subsencodingstr);
verbosity = verbose;
libvlc_log_subscribe(&debug_subscriber, debug_log, &verbosity);
......@@ -425,6 +431,7 @@ void Java_org_videolan_vlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz, jboolean
"--no-drop-late-frames",
"--avcodec-fast",
"--avcodec-threads=0",
"--subsdec-encoding", subsencodingstr,
enable_time_stretch ? "--audio-time-stretch" : "--no-audio-time-stretch",
use_opensles ? "--aout=opensles" : "--aout=android_audiotrack",
};
......@@ -432,6 +439,8 @@ void Java_org_videolan_vlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz, jboolean
setLong(env, thiz, "mLibVlcInstance", (jlong)(intptr_t) instance);
(*env)->ReleaseStringUTFChars(env, subsencoding, subsencodingstr);
if (!instance)
{
jclass exc = (*env)->FindClass(env, "org/videolan/vlc/LibVlcException");
......
......@@ -176,6 +176,8 @@
<string name="aout_opensles">OpenSL ES</string>
<string name="enable_time_stretching_audio">Enable time-stretching audio</string>
<string name="enable_time_stretching_audio_detail">Speed up and slow down audio without changing the pitch (requires a fast device)</string>
<string name="subtitles_prefs_category">Subtitles</string>
<string name="subtitles_text_encoding">Text encoding</string>
<string-array name="screen_orientation_list">
<item>@string/screen_orientation_sensor</item>
......@@ -194,6 +196,95 @@
<item>9</item> <!-- 9 ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT -->
</string-array>
<string-array name="subtitles_encoding_list">
<item>Default (Windows-1252)</item>
<item>Universal (UTF-8)</item>
<item>Universal (UTF-16)</item>
<item>Universal (big endian UTF-16)</item>
<item>Universal (little endian UTF-16)</item>
<item>Universal, Chinese (GB18030)</item>
<item>Western European (Latin-9)</item>
<item>Western European (Windows-1252)</item>
<item>Western European (IBM 00850)</item>
<item>Eastern European (Latin-2)</item>
<item>Eastern European (Windows-1250)</item>
<item>Esperanto (Latin-3)</item>
<item>Nordic (Latin-6)</item>
<item>Cyrillic (Windows-1251)</item>
<item>Russian (KOI8-R)</item>
<item>Ukrainian (KOI8-U)</item>
<item>Arabic (ISO 8859-6)</item>
<item>Arabic (Windows-1256)</item>
<item>Greek (ISO 8859-7)</item>
<item>Greek (Windows-1253)</item>
<item>Hebrew (ISO 8859-8)</item>
<item>Hebrew (Windows-1255)</item>
<item>Turkish (ISO 8859-9)</item>
<item>Turkish (Windows-1254)</item>
<item>Thai (TIS 620-2533/ISO 8859-11)</item>
<item>Thai (Windows-874)</item>
<item>Baltic (Latin-7)</item>
<item>Baltic (Windows-1257)</item>
<item>Celtic (Latin-8)</item>
<item>South-Eastern European (Latin-10)</item>
<item>Simplified Chinese (ISO-2022-CN-EXT)</item>
<item>Simplified Chinese Unix (EUC-CN)</item>
<item>Japanese (7-bits JIS/ISO-2022-JP-2)</item>
<item>Japanese Unix (EUC-JP)</item>
<item>Japanese (Shift JIS)</item>
<item>Korean (EUC-KR/CP949)</item>
<item>Korean (ISO-2022-KR)</item>
<item>Traditional Chinese (Big5)</item>
<item>Traditional Chinese Unix (EUC-TW)</item>
<item>Hong-Kong Supplementary (HKSCS)</item>
<item>Vietnamese (VISCII)</item>
<item>Vietnamese (Windows-1258)</item>
</string-array>
<string-array name="subtitles_encoding_values" translatable="false">
<item></item>
<item>UTF-8</item>
<item>UTF-16</item>
<item>UTF-16BE</item>
<item>UTF-16LE</item>
<item>GB18030</item>
<item>ISO-8859-15</item>
<item>Windows-1252</item>
<item>IBM850</item>
<item>ISO-8859-2</item>
<item>Windows-1250</item>
<item>ISO-8859-3</item>
<item>ISO-8859-10</item>
<item>Windows-1251</item>
<item>KOI8-R</item>
<item>KOI8-U</item>
<item>ISO-8859-6</item>
<item>Windows-1256</item>
<item>ISO-8859-7</item>
<item>Windows-1253</item>
<item>ISO-8859-8</item>
<item>Windows-1255</item>
<item>ISO-8859-9</item>
<item>Windows-1254</item>
<item>ISO-8859-11</item>
<item>Windows-874</item>
<item>ISO-8859-13</item>
<item>Windows-1257</item>
<item>ISO-8859-14</item>
<item>ISO-8859-16</item>
<item>ISO-2022-CN-EXT</item>
<item>EUC-CN</item>
<item>ISO-2022-JP-2</item>
<item>EUC-JP</item>
<item>Shift_JIS</item>
<item>CP949</item>
<item>ISO-2022-KR</item>
<item>Big5</item>
<item>ISO-2022-TW</item>
<item>Big5-HKSCS</item>
<item>VISCII</item>
<item>Windows-1258</item>
</string-array>
<string-array name="aouts_froyo">
<item>@string/aout_audiotrack_java</item>
<item>@string/aout_audiotrack</item>
......
......@@ -47,6 +47,15 @@
android:title="@string/clear_history">
</PreferenceScreen>
</PreferenceCategory>
<PreferenceCategory android:title="@string/subtitles_prefs_category">
<ListPreference
android:entries="@array/subtitles_encoding_list"
android:entryValues="@array/subtitles_encoding_values"
android:key="subtitles_text_encoding"
android:title="@string/subtitles_text_encoding"
android:defaultValue=""
android:persistent="true" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/advanced_prefs_category">
<ListPreference
android:defaultValue="@string/aout_audiotrack_java"
......
......@@ -26,6 +26,7 @@ import org.videolan.vlc.gui.video.VideoPlayerActivity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.os.Build;
import android.preference.PreferenceManager;
import android.util.Log;
......@@ -193,6 +194,26 @@ public class LibVLC {
return p.getBoolean("enable_time_stretching_audio", false);
}
public String getSubtitlesEncoding() {
SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(VLCApplication.getAppContext());
return p.getString("subtitles_text_encoding", "");
}
public static synchronized void setSubtitlesEncoding(Context context, String encoding, boolean reset) {
SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(context);
Editor e = pref.edit();
e.putString("subtitles_text_encoding", encoding);
e.commit();
if (reset && sInstance != null) {
try {
sInstance.destroy();
sInstance.init();
} catch (LibVlcException lve) {
Log.e(TAG, "Unable to reinit libvlc: " + lve);
}
}
}
/**
* Initialize the libVLC class
*/
......
......@@ -133,6 +133,18 @@ public class PreferencesActivity extends PreferenceActivity {
}
});
// Subtitles encoding
Preference subtitlesEncoding = (ListPreference)findPreference("subtitles_text_encoding");
subtitlesEncoding.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
String encoding = (String)newValue;
LibVLC.setSubtitlesEncoding(preference.getContext(), encoding, true);
return true;
}
});
// Change verbosity (logcat)
CheckBoxPreference checkboxVerbosity = (CheckBoxPreference) findPreference("enable_verbose_mode");
checkboxVerbosity.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment