Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • videolan/vlc-android
  • thresh/vlc-android
  • Dekans/vlc-android
  • robUx4/vlc-android
  • tguillem/vlc-android
  • Corbax/vlc-android
  • judeosby/vlc-android
  • chouquette/vlc-android
  • washingtonmurphy93/vlc-android
  • wipawanbeadklang540/vlc-android
  • xcorail/vlc-android
  • Aza/vlc-android
  • Skantes/vlc-android
  • filipjares/vlc-android
  • kazemihabib/vlc-android
  • amq10x/vlc-android
  • qadrian370/vlc-android
  • shivanshs9/vlc-android
  • vitaliyg2/vlc-android
  • orgads/vlc-android
  • rom1v/vlc-android
  • evidence/vlc-android
  • lk888/vlc-android
  • Klaus81/vlc-android
  • EwoutH/vlc-android
  • XilasZ/vlc-android
  • pawelpablo1975/vlc-android
  • uae2ae/vlc-android
  • Garf/vlc-android
  • abetatsunori7/vlc-android
  • ePirat/vlc-android
  • magsoft/vlc-android
  • quink/vlc-android
  • Ektos974/vlc-android
  • CymGen30/vlc-android
  • b1ue/vlc-android
  • alessiavalenti8/vlc-android
  • bars27101982/vlc-android
  • billybanda18/vlc-android
  • dklvip/vlc-android
  • sherylynn/vlc-android
  • ramcoach5/vlc-android
  • takise/vlc-android
  • peibolovedie/vlc-android
  • AMHeijboer/vlc-android
  • dahburj/vlc-android
  • gobennyb/vlc-android
  • masripmasrip824/vlc-android
  • bubu/vlc-android
  • tmk907/vlc-android
  • gorbahaaa/vlc-android
  • govind3321/vlc-android
  • jamieboyer42818/vlc-android
  • mrtakilapop/vlc-android
  • kazikarter90/vlc-android
  • chunyie771/vlc-android
  • nop404/vlc-android
  • hcalzazperz/vlc-android
  • zagwojtek69/vlc-android
  • nikonnick24/vlc-android
  • gmohiuddin215/vlc-android
  • stheinthan31/vlc-android
  • rogelioloreto29/vlc-android
  • philippestcyr5/vlc-android
  • Happyheather20/vlc-android
  • jimbobmcgee/vlc-android
  • mohwie/vlc-android
  • HeartBeat1608/vlc-android
  • jahan/vlc-android
  • Kevo1987/vlc-android
  • rrangel3584/vlc-android
  • xfridrich/vlc-android
  • devswami23/vlc-android
  • Isira-Seneviratne/vlc-android
  • PartyPhone22/vlc-android
  • kmajeshkrishnan/vlc-android
  • ramirotorresjr/vlc-android
  • aaronsalas469/vlc-android
  • arnan.np31/vlc-android
  • hkosacki/vlc-android
  • mg0691872/vlc-android
  • louregni/vlc-android
  • ritmapp/vlc-android
  • diegofn/vlc-android
  • s-ayush2903/vlc-android
  • chrisbohn1984/vlc-android
  • alexandre-janniaux/vlc-android
  • optimumpr/vlc-android
  • chirag-jn/vlc-android
  • e9ab98e991ab/vlc-android
  • suvDev/vlc-android
  • killthelord/vlc-android
  • Phoenix/vlc-android
  • soriyallc/vlc-android
  • tda1009/vlc-android
  • rhstone/vlc-android
  • ltnokiago/vlc-android
  • elbrujo1987/vlc-android
  • m1s4k1/vlc-android
  • mdc/vlc-android
  • arnaudj/vlc-android
  • abhinavmarwaha/vlc-android
  • dali546/vlc-android
  • Jeffset/vlc-android
  • megan30/vlc-android
  • lizhengdao/vlc-android
  • YajTPG/vlc-android
  • halcyon/vlc-android
  • ilya.yanok/vlc-android
  • jeramydhallmon/vlc-android
  • tijoemecano77/vlc-android
  • cjcj125125/vlc-android
  • dejan2609/vlc-android
  • JATIN2111999/vlc-android
  • imrohitkumar/vlc-android
  • sagudev/vlc-android
  • ILoveLin/vlc-android
  • tfighiera/vlc-android
  • snehil101/vlc-android
  • MKornelsen/vlc-android
  • m/vlc-android
  • core1024/vlc-android
  • vadimdolgachev/vlc-android
  • Kk77539/vlc-android
  • linzj/vlc-android
  • dantalian-pv/vlc-android
  • admkhalid/vlc-android
  • yaron/vlc-android
  • kn21091974/vlc-android
  • mylove1302/vlc-android
  • roblav96/vlc-android
  • alabiaga/vlc-android
  • kmnaveen101/vlc-android
  • nikiforoff1407/vlc-android
  • Android-Jester/vlc-android
  • frieda.rtwski/vlc-android
  • glaciers7506/vlc-android
  • rahul-gill/vlc-android
  • gaoxugang/vlc-android
  • Rishavgupta12345/vlc-android
  • dinho991556460/vlc-android
  • lighterowl/vlc-android
  • mary-kate/vlc-android
  • adnank20216/vlc-android
  • anthonylgutierrez79/vlc-android
  • Heliottw/vlc-android
  • mu1zix.ft3/vlc-android
  • yvesmaltais1212/vlc-android
  • ereme/vlc-android
  • jhonypalomino829/vlc-android
  • mx1up/vlc-android
  • sjwaddy/vlc-android
  • MohitMandalia/vlc-android
  • temaershov/vlc-android
  • js6pak/vlc-android
  • mishikallu/vlc-android
  • irfanmumtaz008/vlc-android
  • smurfohrachie/vlc-android
  • Goooler/vlc-android
  • eldo203050/vlc-android
  • dejesuszeus99/vlc-android
  • mfkl/vlc-android
  • Samfun75/vlc-android
  • markg85/vlc-android-ipfs
  • doktamelek911/vlc-android
  • wikwity/vlc-android
  • aangelmaker/vlc-android
  • krawczykradek119/vlc-android
  • ylz18180813163/vlc-android
  • galaxy9sx3/vlc-android
  • huajie2020/vlc-android
  • XuanTung95/vlc-android
  • kl/vlc-android
  • melihyolcu83/vlc-android
  • rt1shnik/vlc-android
  • jerryboy307/vlc-android
  • ikeuzochukwu6/vlc-android
  • patrikgolis/vlc-android
  • Ismavv/vlc-android
  • clementosumo/vlc-android
  • joshlamp66/vlc-android
  • nkmoyonyathiericyounge/vlc-android
  • DanTm99/vlc-android
  • Jeffrow41/vlc-android
  • fromphfr/vlc-android
  • 16project/vlc-android
  • Tomas8874/vlc-android
  • fixxxer87/vlc-android
  • sanjay/vlc-android
  • franciscojrp/vlc-android
  • cashellauswaus23/vlc-android
  • hengwu0/vlc-android
  • naythu2020rain/vlc-android
  • TongtengInhole/vlc-android
  • pupdoggy666/vlc-android
  • jcj921013/vlc-android
  • Gc6026/vlc-android
  • crijojc/vlc-android
  • mdrewight/vlc-android
  • davidhaywood0782/vlc-android
  • jbschtt/vlc-android
  • macfarlandcamel/vlc-android
  • syazairi/vlc-android
  • Commander01/vlc-android
  • baileyterry014/vlc-android
  • rodrickfranklin38/vlc-android
  • diego1245hernb/vlc-android
  • anton.canada/vlc-android
  • egazaekb/vlc-android
  • Marissa111113/vlc-android
  • jeinerbruno2/vlc-android
  • wehnie13/vlc-android
  • ozill87/vlc-android
  • legionfso/vlc-android
  • anazahirajoel/vlc-android
  • naomirojas1227/vlc-android
  • xbao/vlc-android
  • antoni.kozubek/vlc-android
  • pajela8482/vlc-android
  • karlfandango55/vlc-android
  • ruanbester07/vlc-android
  • chigita73/vlc-android
  • giu.pat6/vlc-android
  • Aura/vlc-android
  • marcwabo/vlc-android
  • contact.adgrafix/vlc-android
  • exlaverdad/vlc-android
  • simon.marquis88/vlc-android
  • youngkinsamantha421/vlc-android
  • edgard1161/vlc-android
  • agzx77/vlc-android
  • ha7204993/vlc-android
  • alghazwani.jar.6090/vlc-android
  • zrowton1206/vlc-android
  • darek1979513/vlc-android
  • matthiaskett18198/vlc-android
  • kubadyr77/vlc-android
  • romanstudeny1982/vlc-android
  • kumar107375/vlc-android
  • schong0525/vlc-android
  • Kt/vlc-android
  • jovelyn.esconde125/vlc-android
  • corriemacbarnard/vlc-android
  • apisbg91/vlc-android
  • yyusea/vlc-android
  • protechq88/vlc-android
  • rmangaraman/vlc-android
  • soutomikel/vlc-android
  • goregladaleksej5/vlc-android
  • tao/vlc-android
  • aruiz595/vlc-android
  • horvathpeter1202/vlc-android
  • litteh82/vlc-android
  • kerriochoa96/vlc-android
  • skshemul2022/vlc-android
  • popy/vlc-android
  • mizadpanahdev/vlc-android
  • pinarim2035/vlc-android
  • davidgooch1127/vlc-android
  • NyanCatTW1/vlc-android
  • Pendynurcahyo/vlc-android
  • fcartegnie/vlc-android
  • xiaoxiao921/vlc-android
  • rjtoell/vlc-android
  • devanshu6445/vlc-android
  • DopeDo69/vlc-android
  • quimsical/vlc-android
  • nickita.koltsoff/vlc-android
  • zeestander8617/vlc-android
  • alexsonarin06/vlc-android
  • minh189999h/vlc-android
  • JonnycatMeow/vlc-android
  • pup.ragnarok.1984/vlc-android2
  • jlcalderon13/vlc-android
  • franciszekk51214/vlc-android
  • yinsheng996/vlc-android
  • KenN3RD/vlc-android
  • leogps/vlc-android
  • alicuteo0407/vlc-android
  • MessirVoland/vlc-android
  • brett2uk/vlc-android
  • thomas.hermes/vlc-android
  • dgyudin/vlc-android
  • anuoshemohammad/vlc-android
  • r7truong/vlc-android
  • aaa1115910/vlc-android
  • arunkennedy78/vlc-android
  • nicholaszarra0069/vlc-android
  • georgipetrovdochev/vlc-android
  • Nikhil-z/vlc-android
  • misb1033/vlc-android
  • ktcoooot1/vlc-android
  • manmuc5/vlc-android
  • ahwhatisinttaken/vlc-android
  • m.nozka90/vlc-android
  • kabeermuhammad124319/vlc-android
  • ANGELONCE/vlc-android
  • manstabuk/vlc-android
  • yajcoca/vlc-android
  • dreamscell83/vlc-android
  • oldsssteveo/vlc-android
  • c0ff330k/vlc-android
  • ZhangXinmin528/vlc-android
  • lacsimarnald09/vlc-android
  • boykaisaac758/vlc-android
  • ooseidesmond/vlc-android
  • andresbott/vlc-android
  • yolandawanttoplay/vlc-android
  • lapaz17/vlc-android
  • sillyearl0138/vlc-android
  • NF-Repo/vlc-android
  • aaasg4001/vlc-android
  • mongia.puneet/vlc-android
  • slablaykon/vlc-android
  • Shabgardtanha1111/vlc-android
  • Benjamin_Loison/vlc-android
  • ashishami2002/vlc-android
  • Niram7777/vlc-android
  • Yashraj254/vlc-android
  • Choucroute_melba/vlc-android
  • Soete/vlc-android
  • MangalK/vlc-android
  • mohak2003/vlc-android
  • advait-0/vlc-android
  • McLP/vlc-android
  • fhuber/vlc-android
  • sami-sweng/vlc-android
  • josiahcarlson/vlc-android
  • mzych/vlc-android
  • amarradi/vlc-android
330 results
Show changes
Commits on Source (32)
Showing
with 329 additions and 103 deletions
Changes between 0.1.2 and 0.1.3-git:
Changes between 0.1.2 and 0.1.3:
--------------------------------
Core:
* Fix the video output for Android 4.3
Main Application:
* Fix crashes in SQLite management
* Expand playlist subitems
Changes between 0.1.1 and 0.1.2:
......
......@@ -15,6 +15,10 @@ fi
# try to detect NDK version
REL=$(grep -o '^r[0-9]*.*' $ANDROID_NDK/RELEASE.TXT 2>/dev/null|cut -b2-)
case "$REL" in
9*)
GCCVER=4.8
CXXSTL="/"${GCCVER}
;;
8?*)
# we don't use 4.4.3 because it doesn't handle threads correctly.
# TODO : clang?
......@@ -80,7 +84,7 @@ export PATH=${NDK_TOOLCHAIN_PATH}:${PATH}
ANDROID_PATH="`pwd`"
# 1/ libvlc, libvlccore and its plugins
TESTED_HASH=28811d453
TESTED_HASH=9f5c45fa0
if [ ! -d "vlc" ]; then
echo "VLC source not found, cloning"
git clone git://git.videolan.org/vlc.git vlc
......
......@@ -9,4 +9,4 @@
android.library=true
# Project target.
target=android-17
target=android-18
......@@ -9,4 +9,4 @@
android.library=true
# Project target.
target=android-17
target=android-18
......@@ -14,4 +14,4 @@ android.library=true
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
target=android-17
target=android-18
......@@ -2,12 +2,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.videolan.vlc"
android:installLocation="auto"
android:versionCode="1300"
android:versionName="0.1.3-git" >
android:versionCode="1400"
android:versionName="0.1.4" >
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17" />
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.INTERNET" />
......
/*****************************************************************************
* libvlcjni.c
*****************************************************************************
* Copyright © 2010-2012 VLC authors and VideoLAN
* Copyright © 2010-2013 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
......@@ -180,22 +180,14 @@ static libvlc_media_player_t *getMediaPlayer(JNIEnv *env, jobject thiz)
return (libvlc_media_player_t*)(intptr_t)getLong(env, thiz, "mInternalMediaPlayerInstance");
}
static libvlc_media_list_player_t *getMediaListPlayer(JNIEnv *env, jobject thiz)
{
return (libvlc_media_list_player_t*)(intptr_t)getLong(env, thiz, "mMediaListPlayerInstance");
}
static void releaseMediaPlayer(JNIEnv *env, jobject thiz)
{
libvlc_media_list_player_t* p_mlp = getMediaListPlayer(env, thiz);
if (p_mlp)
libvlc_media_player_t* p_mp = getMediaPlayer(env, thiz);
if (p_mp)
{
libvlc_media_list_player_stop(p_mlp);
libvlc_media_list_player_release(p_mlp);
/* libvlc_media_list_player_release frees the media player, so
* we don't free it ourselves. */
libvlc_media_player_stop(p_mp);
libvlc_media_player_release(p_mp);
setLong(env, thiz, "mInternalMediaPlayerInstance", 0);
setLong(env, thiz, "mMediaListPlayerInstance", 0);
}
}
......@@ -211,12 +203,18 @@ static jobject debugBufferInstance = NULL;
static pthread_mutex_t vout_android_lock;
static void *vout_android_surf = NULL;
static void *vout_android_gui = NULL;
static jobject vout_android_java_surf = NULL;
void *jni_LockAndGetAndroidSurface() {
pthread_mutex_lock(&vout_android_lock);
return vout_android_surf;
}
jobject jni_LockAndGetAndroidJavaSurface() {
pthread_mutex_lock(&vout_android_lock);
return vout_android_java_surf;
}
void jni_UnlockAndroidSurface() {
pthread_mutex_unlock(&vout_android_lock);
}
......@@ -316,6 +314,7 @@ static void vlc_event_callback(const libvlc_event_t *ev, void *data)
}
end:
(*env)->DeleteLocalRef(env, bundle);
if (isAttached)
(*myVm)->DetachCurrentThread(myVm);
}
......@@ -339,22 +338,26 @@ void Java_org_videolan_libvlc_LibVLC_attachSurface(JNIEnv *env, jobject thiz, jo
jclass clz;
jfieldID fid;
pthread_mutex_lock(&vout_android_lock);
clz = (*env)->GetObjectClass(env, surf);
fid = (*env)->GetFieldID(env, clz, "mSurface", "I");
if (fid == NULL) {
jthrowable exp = (*env)->ExceptionOccurred(env);
if (exp) {
(*env)->DeleteLocalRef(env, exp);
(*env)->ExceptionClear(env);
clz = (*env)->FindClass(env, "org/videolan/libvlc/LibVlcUtil");
jmethodID methodId = (*env)->GetStaticMethodID(env, clz, "isGingerbreadOrLater", "()Z");
jboolean gingerbreadOrLater = (*env)->CallStaticBooleanMethod(env, clz, methodId);
// Android 2.2 and under don't have ANativeWindow_fromSurface
if(unlikely(!gingerbreadOrLater)) {
clz = (*env)->GetObjectClass(env, surf);
fid = (*env)->GetFieldID(env, clz, "mSurface", "I");
if (fid == NULL) {
jthrowable exp = (*env)->ExceptionOccurred(env);
if (exp) {
(*env)->DeleteLocalRef(env, exp);
(*env)->ExceptionClear(env);
}
fid = (*env)->GetFieldID(env, clz, "mNativeSurface", "I");
}
fid = (*env)->GetFieldID(env, clz, "mNativeSurface", "I");
vout_android_surf = (void*)(*env)->GetIntField(env, surf, fid);
(*env)->DeleteLocalRef(env, clz);
}
vout_android_surf = (void*)(*env)->GetIntField(env, surf, fid);
(*env)->DeleteLocalRef(env, clz);
vout_android_gui = (*env)->NewGlobalRef(env, gui);
pthread_mutex_unlock(&vout_android_lock);
vout_android_java_surf = (*env)->NewGlobalRef(env, surf);
}
void Java_org_videolan_libvlc_LibVLC_detachSurface(JNIEnv *env, jobject thiz) {
......@@ -362,7 +365,10 @@ void Java_org_videolan_libvlc_LibVLC_detachSurface(JNIEnv *env, jobject thiz) {
vout_android_surf = NULL;
if (vout_android_gui != NULL)
(*env)->DeleteGlobalRef(env, vout_android_gui);
if (vout_android_java_surf != NULL)
(*env)->DeleteGlobalRef(env, vout_android_java_surf);
vout_android_gui = NULL;
vout_android_java_surf = NULL;
pthread_mutex_unlock(&vout_android_lock);
}
......@@ -515,6 +521,10 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
"--no-stats",
"--no-plugins-cache",
"--no-drop-late-frames",
/* The VLC default is to pick the highest resolution possible
* (i.e. 1080p). For mobile, pick a more sane default for slow
* mobile data networks and slower hardware. */
"--preferred-resolution", "360",
"--avcodec-fast",
"--avcodec-threads=0",
"--subsdec-encoding", subsencodingstr,
......@@ -673,7 +683,6 @@ static void create_player_and_play(JNIEnv* env, jobject thiz,
libvlc_media_list_t* p_mlist = getMediaList(env, thiz);
/* Create a media player playing environment */
libvlc_media_list_player_t* p_mlp = libvlc_media_list_player_new((libvlc_instance_t*)(intptr_t)instance);
libvlc_media_player_t *mp = libvlc_media_player_new((libvlc_instance_t*)(intptr_t)instance);
jobject myJavaLibVLC = (*env)->NewGlobalRef(env, thiz);
......@@ -702,14 +711,49 @@ static void create_player_and_play(JNIEnv* env, jobject thiz,
for(int i = 0; i < (sizeof(mp_events) / sizeof(*mp_events)); i++)
libvlc_event_attach(ev, mp_events[i], vlc_event_callback, myVm);
libvlc_media_list_player_set_media_list(p_mlp, p_mlist);
libvlc_media_list_player_set_media_player(p_mlp, mp);
/* Keep a pointer to this media player */
setLong(env, thiz, "mMediaListPlayerInstance", (jlong)(intptr_t)p_mlp);
setLong(env, thiz, "mInternalMediaPlayerInstance", (jlong)(intptr_t)mp);
libvlc_media_list_player_play_item_at_index(p_mlp, position);
setInt(env, thiz, "mInternalMediaPlayerIndex", (jint)position);
libvlc_media_list_lock(p_mlist);
libvlc_media_t* p_md = libvlc_media_list_item_at_index(p_mlist, position);
libvlc_media_list_unlock(p_mlist);
libvlc_media_player_set_media(mp, p_md);
libvlc_media_player_play(mp);
}
jint Java_org_videolan_libvlc_LibVLC_expandMedia(JNIEnv *env, jobject thiz)
{
int current_position = getInt(env, thiz, "mInternalMediaPlayerIndex");
libvlc_media_list_t* p_mlist = getMediaList(env, thiz);
libvlc_media_list_lock(p_mlist);
libvlc_media_t* p_md = libvlc_media_list_item_at_index(p_mlist, current_position);
libvlc_media_list_unlock(p_mlist);
libvlc_media_list_t* p_subitems = libvlc_media_subitems(p_md);
libvlc_media_release(p_md);
if(p_subitems) {
// Expand any subitems if needed
int subitem_count = libvlc_media_list_count(p_subitems);
if(subitem_count > 0) {
LOGD("Found %d subitems, expanding", subitem_count);
libvlc_media_list_lock(p_mlist);
for(int i = subitem_count - 1; i >= 0; i--) {
libvlc_media_list_insert_media(p_mlist, libvlc_media_list_item_at_index(p_subitems, i), current_position+1);
}
libvlc_media_list_remove_index(p_mlist, current_position);
libvlc_media_list_unlock(p_mlist);
}
libvlc_media_list_release(p_subitems);
if(subitem_count > 0) {
create_player_and_play(env, thiz,
getLong(env, thiz, "mLibVlcInstance"), current_position);
return (jint)current_position;
} else
return -1;
} else {
return -1;
}
}
jint Java_org_videolan_libvlc_LibVLC_readMedia(JNIEnv *env, jobject thiz,
......@@ -766,6 +810,10 @@ void Java_org_videolan_libvlc_LibVLC_getMediaListItems(
libvlc_media_list_unlock( p_mlist );
}
void Java_org_videolan_libvlc_LibVLC_removeIndex(JNIEnv *env, jobject thiz, jlong instance, jint position) {
libvlc_media_list_remove_index((libvlc_media_list_t*)(intptr_t)instance, position);
}
jfloat Java_org_videolan_libvlc_LibVLC_getRate(JNIEnv *env, jobject thiz) {
libvlc_media_player_t* mp = getMediaPlayer(env, thiz);
if(mp)
......@@ -994,14 +1042,14 @@ end:
jboolean Java_org_videolan_libvlc_LibVLC_hasMediaPlayer(JNIEnv *env, jobject thiz)
{
return !!getMediaListPlayer(env, thiz);
return !!getMediaPlayer(env, thiz);
}
jboolean Java_org_videolan_libvlc_LibVLC_isPlaying(JNIEnv *env, jobject thiz)
{
libvlc_media_list_player_t *mp = getMediaListPlayer(env, thiz);
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
return !!libvlc_media_list_player_is_playing(mp);
return !!libvlc_media_player_is_playing(mp);
else
return 0;
}
......@@ -1016,37 +1064,46 @@ jboolean Java_org_videolan_libvlc_LibVLC_isSeekable(JNIEnv *env, jobject thiz)
void Java_org_videolan_libvlc_LibVLC_play(JNIEnv *env, jobject thiz)
{
libvlc_media_list_player_t *mp = getMediaListPlayer(env, thiz);
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
libvlc_media_list_player_play(mp);
libvlc_media_player_play(mp);
}
void Java_org_videolan_libvlc_LibVLC_pause(JNIEnv *env, jobject thiz)
{
libvlc_media_list_player_t *mp = getMediaListPlayer(env, thiz);
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
libvlc_media_list_player_pause(mp);
libvlc_media_player_pause(mp);
}
void Java_org_videolan_libvlc_LibVLC_stop(JNIEnv *env, jobject thiz)
{
libvlc_media_list_player_t *mp = getMediaListPlayer(env, thiz);
libvlc_media_player_t *mp = getMediaPlayer(env, thiz);
if (mp)
libvlc_media_list_player_stop(mp);
libvlc_media_player_stop(mp);
}
void Java_org_videolan_libvlc_LibVLC_previous(JNIEnv *env, jobject thiz)
{
libvlc_media_list_player_t *mp = getMediaListPlayer(env, thiz);
if (mp)
libvlc_media_list_player_previous(mp);
int current_position = getInt(env, thiz, "mInternalMediaPlayerIndex");
if(current_position-1 >= 0) {
setInt(env, thiz, "mInternalMediaPlayerIndex", (jint)(current_position-1));
create_player_and_play(env, thiz,
getLong(env, thiz, "mLibVlcInstance"), current_position-1);
}
}
void Java_org_videolan_libvlc_LibVLC_next(JNIEnv *env, jobject thiz)
{
libvlc_media_list_player_t *mp = getMediaListPlayer(env, thiz);
if (mp)
libvlc_media_list_player_next(mp);
libvlc_media_list_t* p_mlist = getMediaList(env, thiz);
int current_position = getInt(env, thiz, "mInternalMediaPlayerIndex");
if(current_position+1 < libvlc_media_list_count(p_mlist)) {
setInt(env, thiz, "mInternalMediaPlayerIndex", (jint)(current_position+1));
create_player_and_play(env, thiz,
getLong(env, thiz, "mLibVlcInstance"), current_position+1);
}
}
jint Java_org_videolan_libvlc_LibVLC_getVolume(JNIEnv *env, jobject thiz)
......
......@@ -263,12 +263,12 @@ jbyteArray Java_org_videolan_libvlc_LibVLC_getThumbnail(JNIEnv *env, jobject thi
libvlc_media_player_play(mp);
libvlc_media_player_set_position(mp, THUMBNAIL_POSITION);
int loops = 100;
for (;;) {
float pos = libvlc_media_player_get_position(mp);
if (pos > THUMBNAIL_POSITION || !loops--)
const int wait_time = 50000;
const int max_attempts = 100;
for (int i = 0; i < max_attempts; ++i) {
if (libvlc_media_player_is_playing(mp) && libvlc_media_player_get_position(mp) >= THUMBNAIL_POSITION)
break;
usleep(50000);
usleep(wait_time);
}
/* Wait for the thumbnail to be generated. */
......
......@@ -8,7 +8,7 @@
# project structure.
# Project target.
target=android-17
target=android-18
android.library.reference.1=../java-libs/ActionBarSherlock
android.library.reference.2=../java-libs/SlidingMenu
android.library.reference.3=../java-libs/WheelView
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/history_view_play"
android:title="@string/play" />
<item
android:id="@+id/history_view_delete"
android:title="@string/delete" />
</menu>
......@@ -138,7 +138,7 @@
<!-- Preferences -->
<string name="preferences">Préférences</string>
<string name="library_prefs_category">Bibliothèque multimédia</string>
<string name="directories_summary">Sélectionnez les repertoires de votre bilbiothèque multimédia</string>
<string name="directories_summary">Sélectionnez les repertoires de votre bibliothèque multimédia</string>
<string name="add_custom_path">Ajouter un répertoire</string>
<string name="add_custom_path_description">Entrer un répertoire additionnel à scanner:</string>
<string name="remove_custom_path">Retirer le répertoire</string>
......
/*****************************************************************************
* LibVLC.java
*****************************************************************************
* Copyright © 2010-2012 VLC authors and VideoLAN
* Copyright © 2010-2013 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
......@@ -38,8 +38,8 @@ public class LibVLC {
/** libVLC instance C pointer */
private long mLibVlcInstance = 0; // Read-only, reserved for JNI
/** libvlc_media_list_player pointer */
private long mMediaListPlayerInstance = 0; // Read-only, reserved for JNI
/** libvlc_media_player pointer and index */
private int mInternalMediaPlayerIndex = 0; // Read-only, reserved for JNI
private long mInternalMediaPlayerInstance = 0; // Read-only, reserved for JNI
/** libvlc_media_list_t pointer */
private long mMediaListInstance = 0; // Read-only, reserved for JNI
......@@ -397,6 +397,12 @@ public class LibVLC {
return mIsBufferingLog;
}
/** Media list functions **/
public void removeIndex(int position) {
removeIndex(mMediaListInstance, position);
}
private native void removeIndex(long media_list_instance, int position);
/**
* Read a media
* @param instance: the instance of libVLC
......@@ -566,6 +572,15 @@ public class LibVLC {
*/
public native void getMediaListItems(ArrayList<String> arl);
/**
* A function to flatten the playlist. This function checks the
* currently playing media. If there are any subitems, it will
* expand them and replace the current media.
*
* @return the index of the media was expanded, and -1 if no media was expanded
*/
public native int expandMedia();
/**
* Return the length of the stream, in milliseconds
*/
......
/*****************************************************************************
* AudioService.java
*****************************************************************************
* Copyright © 2011-2012 VLC authors and VideoLAN
* Copyright © 2011-2013 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -94,6 +94,7 @@ public class AudioService extends Service {
public static final String ACTION_REMOTE_LAST_PLAYLIST = "org.videolan.vlc.remote.LastPlaylist";
public static final String ACTION_WIDGET_INIT = "org.videolan.vlc.widget.INIT";
public static final String ACTION_WIDGET_UPDATE = "org.videolan.vlc.widget.UPDATE";
public static final String ACTION_WIDGET_UPDATE_COVER = "org.videolan.vlc.widget.UPDATE_COVER";
public static final String ACTION_WIDGET_UPDATE_POSITION = "org.videolan.vlc.widget.UPDATE_POSITION";
public static final String WIDGET_PACKAGE = "org.videolan.vlc";
......@@ -390,6 +391,7 @@ public class AudioService extends Service {
switch (msg.getData().getInt("event")) {
case EventHandler.MediaPlayerPlaying:
Log.i(TAG, "MediaPlayerPlaying");
service.executeUpdate();
if (service.mCurrentMedia == null)
return;
......@@ -414,6 +416,7 @@ public class AudioService extends Service {
service.changeAudioFocus(true);
service.setRemoteControlClientPlaybackState(EventHandler.MediaPlayerPlaying);
service.showNotification();
if (!service.mWakeLock.isHeld())
service.mWakeLock.acquire();
break;
......@@ -468,7 +471,8 @@ public class AudioService extends Service {
private void handleVout() {
Log.i(TAG, "Obtained video track");
mMediaList.clear();
hideNotification();
// Preserve playback when switching to video
hideNotification(false);
// Don't crash if user stopped the media
if(mCurrentMedia == null) return;
......@@ -603,8 +607,18 @@ public class AudioService extends Service {
}
private void hideNotification() {
hideNotification(true);
}
/**
* Hides the VLC notification and stops the service.
*
* @param stopPlayback True to also stop playback at the same time. Set to false to preserve playback (e.g. for vout events)
*/
private void hideNotification(boolean stopPlayback) {
stopForeground(true);
stopSelf();
if(stopPlayback)
stopSelf();
}
private void pause() {
......@@ -638,34 +652,58 @@ public class AudioService extends Service {
}
private void next() {
int index = mMediaList.indexOf(mCurrentMedia);
mPrevious.push(mCurrentMedia);
if (mRepeating == RepeatType.Once && index < mMediaList.size())
mCurrentMedia = mMediaList.get(index);
else if (mShuffling && mPrevious.size() < mMediaList.size()) {
while (mPrevious.contains(mCurrentMedia = mMediaList
.get((int) (Math.random() * mMediaList.size()))))
;
} else if (!mShuffling && index < mMediaList.size() - 1) {
mCurrentMedia = mMediaList.get(index + 1);
// Try to expand any items present
int pos = mLibVLC.expandMedia();
if(pos >= 0) {
Log.d(TAG, "Found subitems, updating media display");
ArrayList<String> mediaPathList = new ArrayList<String>();
mLibVLC.getMediaListItems(mediaPathList);
mMediaList.clear();
mPrevious.clear();
for(int i = 0; i < mediaPathList.size(); i++)
mMediaList.add(new Media(mediaPathList.get(i), i));
mLibVLCPlaylistActive = true;
mCurrentMedia = mMediaList.get(pos);
final AudioService service = this;
mVlcEventHandler.postDelayed(new Runnable() {
@Override
public void run() {
service.executeUpdate();
}
}, 1000);
} else {
if (mRepeating == RepeatType.All && mMediaList.size() > 0)
mCurrentMedia = mMediaList.get(0);
else {
stop();
return;
// No subitems; play the next item.
int index = mMediaList.indexOf(mCurrentMedia);
mPrevious.push(mCurrentMedia);
if (mRepeating == RepeatType.Once && index < mMediaList.size())
mCurrentMedia = mMediaList.get(index);
else if (mShuffling && mPrevious.size() < mMediaList.size()) {
while (mPrevious.contains(mCurrentMedia = mMediaList
.get((int) (Math.random() * mMediaList.size()))))
;
} else if (!mShuffling && index < mMediaList.size() - 1) {
mCurrentMedia = mMediaList.get(index + 1);
} else {
if (mRepeating == RepeatType.All && mMediaList.size() > 0)
mCurrentMedia = mMediaList.get(0);
else {
stop();
return;
}
}
if(mLibVLCPlaylistActive) {
if(mRepeating == RepeatType.None)
mLibVLC.next();
else if(mRepeating == RepeatType.Once)
mLibVLC.playIndex(index);
else
mLibVLC.playIndex(mMediaList.indexOf(mCurrentMedia));
} else {
mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
}
}
if(mLibVLCPlaylistActive) {
if(mRepeating == RepeatType.None)
mLibVLC.next();
else if(mRepeating == RepeatType.Once)
mLibVLC.playIndex(index);
else
mLibVLC.playIndex(mMediaList.indexOf(mCurrentMedia));
} else {
mLibVLC.readMedia(mCurrentMedia.getLocation(), true);
}
mHandler.sendEmptyMessage(SHOW_PROGRESS);
setUpRemoteControlClient();
showNotification();
......@@ -1027,9 +1065,13 @@ public class AudioService extends Service {
}
};
private void updateWidget(Context context)
{
private void updateWidget(Context context) {
Log.d(TAG, "Updating widget");
updateWidgetState(context);
updateWidgetCover(context);
}
private void updateWidgetState(Context context) {
Intent i = new Intent();
i.setClassName(WIDGET_PACKAGE, WIDGET_CLASS);
i.setAction(ACTION_WIDGET_UPDATE);
......@@ -1044,6 +1086,15 @@ public class AudioService extends Service {
}
i.putExtra("isplaying", mLibVLC.isPlaying());
sendBroadcast(i);
}
private void updateWidgetCover(Context context)
{
Intent i = new Intent();
i.setClassName(WIDGET_PACKAGE, WIDGET_CLASS);
i.setAction(ACTION_WIDGET_UPDATE_COVER);
Bitmap cover = mCurrentMedia != null ? AudioUtil.getCover(this, mCurrentMedia, 64) : null;
i.putExtra("cover", cover);
......@@ -1058,6 +1109,8 @@ public class AudioService extends Service {
timestamp - mWidgetPositionTimestamp < mCurrentMedia.getLength() / 50)
return;
updateWidgetState(context);
mWidgetPositionTimestamp = timestamp;
Intent i = new Intent();
i.setClassName(WIDGET_PACKAGE, WIDGET_CLASS);
......
......@@ -35,6 +35,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
......@@ -111,6 +112,37 @@ public class MediaDatabase {
super(context, DB_NAME, null, DB_VERSION);
}
@Override
public SQLiteDatabase getWritableDatabase() {
SQLiteDatabase db;
try {
return super.getWritableDatabase();
} catch(SQLiteException e) {
try {
db = SQLiteDatabase.openOrCreateDatabase(VLCApplication.getAppContext().getDatabasePath(DB_NAME), null);
} catch(SQLiteException e2) {
Log.w(TAG, "SQLite database could not be created! Media library cannot be saved.");
db = SQLiteDatabase.create(null);
}
}
int version = db.getVersion();
if (version != DB_VERSION) {
db.beginTransaction();
try {
if (version == 0) {
onCreate(db);
} else {
onUpgrade(db, version, DB_VERSION);
}
db.setVersion(DB_VERSION);
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
return db;
}
public void dropMediaTableQuery(SQLiteDatabase db) {
String query = "DROP TABLE " + MEDIA_TABLE_NAME + ";";
db.execSQL(query);
......
......@@ -70,10 +70,10 @@ public class VLCApplication extends Application {
getBaseContext().getResources().getDisplayMetrics());
}
instance = this;
// Initialize the database soon enough to avoid any race condition and crash
MediaDatabase.getInstance(this);
instance = this;
}
/**
......
......@@ -21,6 +21,7 @@
package org.videolan.vlc.gui;
import java.io.IOException;
import java.util.List;
import org.videolan.libvlc.LibVLC;
import org.videolan.vlc.AudioServiceController;
......@@ -172,7 +173,8 @@ public class DirectoryViewFragment extends SherlockListFragment implements ISort
try {
if (LibVLC.getExistingInstance() == null
|| !LibVLC.getExistingInstance().hasVideoTrack(mediaFile)) {
audioController.load(mDirectoryAdapter.getAllMediaLocations(), p-1); /* p-1 to exclude ".," */
List<String> mediaLocations = mDirectoryAdapter.getAllMediaLocations();
audioController.load(mediaLocations, mediaLocations.indexOf(mediaFile));
AudioPlayerActivity.start(getActivity());
} else {
VideoPlayerActivity.start(getActivity(), mediaFile);
......
......@@ -31,7 +31,9 @@ import org.videolan.vlc.R;
import org.videolan.vlc.Util;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.WeakHandler;
import org.videolan.vlc.gui.audio.AudioUtil;
import android.graphics.Bitmap;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
......@@ -102,7 +104,11 @@ public class HistoryAdapter extends BaseAdapter {
holderText = m.getSubtitle();
holder.text.setText(holderText);
holder.icon.setImageResource(R.drawable.icon);
Bitmap b = AudioUtil.getCover(VLCApplication.getAppContext(), m, 64);
if(b != null)
holder.icon.setImageBitmap(b);
else
holder.icon.setImageResource(R.drawable.icon);
return v;
}
......
......@@ -20,15 +20,21 @@
*****************************************************************************/
package org.videolan.vlc.gui;
import org.videolan.libvlc.LibVLC;
import org.videolan.vlc.AudioServiceController;
import org.videolan.vlc.R;
import org.videolan.vlc.gui.audio.AudioPlayerActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.ListView;
import com.actionbarsherlock.app.SherlockListFragment;
......@@ -54,19 +60,51 @@ public class HistoryFragment extends SherlockListFragment {
{
View v = inflater.inflate(R.layout.history_list, container, false);
setListAdapter(mHistoryAdapter);
final ListView listView = (ListView)v.findViewById(android.R.id.list);
registerForContextMenu(listView);
return v;
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
MenuInflater menuInflater = getActivity().getMenuInflater();
menuInflater.inflate(R.menu.history_view, menu);
}
@Override
public void onListItemClick(ListView l, View v, int p, long id) {
playListIndex(p);
}
private void playListIndex(int position) {
AudioServiceController audioController = AudioServiceController.getInstance();
audioController.load(mHistoryAdapter.getAllURIs(), p, true, true);
audioController.load(mHistoryAdapter.getAllURIs(), position, true, true);
Intent intent = new Intent(getActivity(), AudioPlayerActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
if(!getUserVisibleHint()) return super.onContextItemSelected(item);
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
if(info == null) // info can be null
return super.onContextItemSelected(item);
int id = item.getItemId();
if(id == R.id.history_view_play) {
playListIndex(info.position);
return true;
} else if(id == R.id.history_view_delete) {
LibVLC.getExistingInstance().removeIndex(info.position);
mHistoryAdapter.refresh();
return true;
}
return super.onContextItemSelected(item);
}
public void refresh() {
Log.d(TAG, "Refreshing view!");
if( mHistoryAdapter != null )
......
......@@ -55,6 +55,7 @@ import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.text.InputType;
import android.util.Log;
import android.view.Display;
import android.view.LayoutInflater;
......@@ -642,6 +643,7 @@ public class MainActivity extends SherlockFragmentActivity {
private void onOpenMRL() {
AlertDialog.Builder b = new AlertDialog.Builder(this);
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL);
b.setTitle(R.string.open_mrl_dialog_title);
b.setMessage(R.string.open_mrl_dialog_msg);
b.setView(input);
......
......@@ -286,14 +286,16 @@ public class VideoGridFragment extends SherlockGridFragment implements ISortable
startActivity(intent);
return true;
case R.id.video_list_delete:
final int positionDelete = position;
Media media = mVideoAdapter.getItem(position);
AlertDialog alertDialog = CommonDialogs.deleteMedia(
getActivity(),
mVideoAdapter.getItem(positionDelete).getLocation(),
new VlcRunnable() {
media.getLocation(),
new VlcRunnable(media) {
@Override
public void run(Object o) {
mVideoAdapter.remove(mVideoAdapter.getItem(positionDelete));
Media media = (Media) o;
mMediaLibrary.getMediaItems().remove(media);
mVideoAdapter.remove(media);
}
});
alertDialog.show();
......