B4A Library [Lib] MediaBrowser

Hello,

This library lists the media content (audio, image and video) of the MediaStore (a database containing meta data for all available media on both internal and external storage devices). It includes an audio player and a media scanner (to scan the new media and add them to the MediaStore).

I added new functions to the library esAudioMediaBrowser provided by Lagore, improved a bit the existing ones, and extended the stuff to images and videos.
The demo (a media gallery) needs the libs Reflection & StringUtils. It displays only files stored on your external SD card (but the lib can handle internal files).

This lib does not work with Android versions < Gingerbread (2.3).

List of properties and methods:
  • GetAudioFieldByID (External As Boolean, ID As Long, Field As String) As String
    Returns a field from the MediaStore about the specified audio file.
    Examples of field: FIELD_COMPOSER, FIELD_DATE_MODIFIED, FIELD_MIME_TYPE, FIELD_SIZE...
  • GetAudioFileInfo (Path As String, File As String) As Map
    Returns a Map containing info from the MediaStore about an audio file.
    The fields that are returned are:
    "ID"
    "Title"
    "Album"
    "Artist"
    "Track"
    "Year"
    "Location"
    "DisplayName"
    "Duration" (in ms)
  • GetAudioFileInfoByID (External As Boolean, ID As Long) As Map
    Returns a Map containing info from the MediaStore about an audio file.
    The fields that are returned are:
    "ID"
    "Title"
    "Album"
    "Artist"
    "Track"
    "Year"
    "Location"
    "DisplayName"
    "Duration" (in ms)
  • GetExifAttribute (Location As String, Attribute As String) As String
    Returns the requested attribute from the Exif data of the specified image.
    Location = complete path name for the file.
    The complete list of attributes can be found here: https://developer.android.com/reference/android/media/ExifInterface
  • GetExifLatLong (Location As String, LatLong As Float()) As Boolean
    Stores the latitude and longitude value of the specified image in a float array. Returns False if these Exif data are not available.
    Location = complete path name for the file.
  • GetExtImageFileInfo (Location As String) As Map
    Returns a Map containing info from the MediaStore about an external image file.
    Location = complete path name for the file.
    The fields that are returned are:
    "ID"
    "Location"
    "DisplayName"
    "DateTaken" (in ticks from 1970)
    "Height" (with Android 3.0+)
    "Width" (with Android 3.0+)
    "Size" (in bytes)
  • GetExtVideoFileInfo (Location As String) As Map
    Returns a Map containing info from the MediaStore about an external video file.
    Location = complete path name for the file.
    The fields that are returned are:
    "ID"
    "Location"
    "DisplayName"
    "DateTaken" (in ticks from 1970)
    "Resolution" (can be Null for some files)
    "Size" (in bytes)
  • GetImageDimensions (Location As String) As Map
    Returns a map containing width and height of the specified file.
    Location = complete path name for the file.
  • GetImageFieldByID (External As Boolean, ID As Long, Field As String) As String
    Returns a field from the MediaStore about the specified image file.
    Examples of field: FIELD_DATE_MODIFIED, FIELD_MIME_TYPE, FIELD_ORIENTATION...
  • GetImageFileInfoByID (External As Boolean, ID As Long) As Map
    Returns a Map containing info from the MediaStore about an image file.
    The fields that are returned are:
    "ID"
    "Location"
    "DisplayName"
    "DateTaken" (in ticks from 1970)
    "Height" (with Android 3.0+)
    "Width" (with Android 3.0+)
    "Size" (in bytes)
  • GetImgThumbnailByID (ID As Long, Mini As Boolean) As android.graphics.Bitmap
    Returns the micro thumbnail (96x96) or mini thumbnail (512x384) of an image file (it is generated if it doesn't exist).
  • GetMediaAudioList (External As Boolean, SortCol As String) As Map
    Returns a Map containing a list of all Audio files in the MediaStore which can be sorted.
    The allowed fields for sorting are:
    Null (= FIELD_ID)
    FIELD_ALBUM
    FIELD_ARTIST
    FIELD_COMPOSER
    FIELD_DATA (location)
    FIELD_DATE_ADDED
    FIELD_DATE_MODIFIED
    FIELD_DISPLAY_NAME
    FIELD_DURATION
    FIELD_MIME_TYPE
    FIELD_SIZE
    FIELD_TITLE
    FIELD_TRACK
    FIELD_YEAR
    The fields that are returned are:
    "ID"
    "Title"
    "Album"
    "Artist"
    "Track"
    "Year"
    "Location"
    "DisplayName"
    "Duration" (in ms)
  • GetMediaImageList (External As Boolean, SortCol As String) As Map
    Returns a Map containing a list of all Image files in the MediaStore which can be sorted.
    The allowed fields for sorting are:
    Null (= FIELD_ID)
    FIELD_DATA (location)
    FIELD_DATE_ADDED
    FIELD_DATE_MODIFIED
    FIELD_DATE_TAKEN
    FIELD_DISPLAY_NAME
    FIELD_HEIGHT
    FIELD_MIME_TYPE
    FIELD_ORIENTATION
    FIELD_SIZE
    FIELD_TITLE
    FIELD_WIDTH
    The fields that are returned are:
    "ID"
    "Location"
    "DisplayName"
    "DateTaken" (in ticks from 1970)
    "Height" (with Android 3.0+)
    "Width" (with Android 3.0+)
    "Size" (in bytes)
  • GetMediaVideoList (External As Boolean, SortCol As String) As Map
    Returns a Map containing a list of all Video files in the MediaStore which can be sorted.
    The allowed fields for sorting are:
    Null (= FIELD_ID)
    FIELD_DATA (location)
    FIELD_DATE_ADDED
    FIELD_DATE_MODIFIED
    FIELD_DATE_TAKEN
    FIELD_DISPLAY_NAME
    FIELD_MIME_TYPE
    FIELD_RESOLUTION
    FIELD_SIZE
    FIELD_TITLE
    The fields that are returned are:
    "ID"
    "Location"
    "DisplayName"
    "DateTaken" (in ticks from 1970)
    "Resolution" (can be Null for some files)
    "Size" (in bytes)
  • GetVideoFieldByID (External As Boolean, ID As Long, Field As String) As String
    Returns a field from the MediaStore about the specified video file.
    Examples of field: FIELD_DATE_ADDED, FIELD_DATE_MODIFIED, FIELD_MIME_TYPE...
  • GetVideoFileInfoByID (External As Boolean, ID As Long) As Map
    Returns a Map containing info from the MediaStore about a video file.
    The fields that are returned are:
    "ID"
    "Location"
    "DisplayName"
    "DateTaken" (in ticks from 1970)
    "Resolution" (can be Null for some files)
    "Size" (in bytes)
  • GetVideoThumbnailByID (ID As Long, Mini As Boolean) As android.graphics.Bitmap
    Returns the micro thumbnail (96x96) or mini thumbnail (512x384) of a video file (it is generated if it doesn't exist).
    There's a known bug on some Android versions with micro thumbnails:
    If the micro thumbnail can't be generated (e.g. video file format not recognized), the result is either null or a random thumbnail. Thus, for video files, it is strongly recommended to check if the mini thumbnail is initialized before trying to get the micro thumbnail.
  • Initialize (EventName As String)
  • MediaAudioPlay (External As Boolean, ID As Int)
    Plays an audio file.
    Raises the "MediaCompleted" event when the file end is reached.
  • MediaIsLooping As Boolean
    Checks whether the player is looping or non-looping.
  • MediaIsPlaying As Boolean
  • MediaLength As Int
    Returns the duration in ms.
  • MediaPause
  • MediaPosition As Int
    Gets the current playback position.
  • MediaResume
  • MediaSeek (position As Int)
    Seeks to specified time position (in ms).
    Raises the event "SeekCompleted" when the position change has been completed.
  • MediaSetLooping (Looping As Boolean)
    Sets the player to be looping or non-looping.
  • MediaSetVolume (leftVolume As Float, rightVolume As Float)
    Sets the volume on this player (and this player only).
    Note that the passed volume values are raw scalars. UI controls should be scaled logarithmically.
    This function must be called AFTER MediaAudioPlay.
  • MediaStop
    Stops the playback and releases the allocated resources.
  • ScanNewMedia (Paths As String())
    Requests the media scanner to scan the given files and add them to the MediaStore.
    Raises the "ScanCompleted" event after each file is scanned.
Warning:
There's a known bug on some Android versions with micro thumbnails:
If the micro thumbnail can't be generated (e.g. video file format not recognized), the result is either null or a random thumbnail. Thus, for video files, it is strongly recommended to check if the mini thumbnail is initialized before trying to get the micro thumbnail.


v1.2:
I fixed two bugs.

v1.21:
I removed the excessive log entries.
I removed all the Try/Catch that silently trapped errors.

v1.3:
This version requires Java 7 and B4A v3.82+.
I added 3 functions:
- GetImageFileInfoByID(External As Boolean, ID As Long) As Map;
- GetVideoFileInfoByID(External As Boolean, ID As Long) As Map;
- ScanNewMedia(Paths() As String).
I updated the demo so it works with recent Android versions.

v1.31:
I fixed a mistake in two functions introduced in v1.3.

v1.4:
I fixed an issue with API 30;
I added five functions: GetAudioFieldByID, GetImageFieldByID, GetVideoFieldByID, GetExifAttribute and GetExifLatLong;
I added a few FIELD constants;
I updated the demo to display the following fields: composer, orientation, latitude and longitude.

Enjoy,
Fred
 

Attachments

  • MediaBrowser v1.4.zip
    80.7 KB · Views: 1,008
Last edited:

ibra939

Active Member
Licensed User
Longtime User
Nice media to create
 

Informatix

Expert
Licensed User
Longtime User
Hello Informatix,

Thank you for this wonderful library. Works great.

I use it to show pictures and videos on a web page, each item has a checkbox with an id. (The id returned by your library)
I use that id to find the item on the server (delete, etc), but I can not find pictures and videos through the id, location only.

Please, would be possible add these 2 methods?

GetImageFileInfoByID (External AsBoolean, ID AsLong) As Map
GetVideoFileInfoByID
(External AsBoolean, ID AsLong) As Map

Thanks again
I added these functions to the new version (see post #1). I also added a function to force the scan of new media.
 

mlc

Active Member
Licensed User
Longtime User
Hello Frederic,

Sorry to bother, but with the new version I get this error message:

B4X:
java.lang.ClassNotFoundException: flm$media$browser$MediaBrowser
    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:544)
    at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:516)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:320)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at mlc.wifitransfer.main.afterFirstLayout(main.java:91)
    at mlc.wifitransfer.main.access$100(main.java:16)
    at mlc.wifitransfer.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3691)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
    at dalvik.system.NativeStart.main(Native Method)

and the app does not start.
 

Informatix

Expert
Licensed User
Longtime User
Hello Frederic,

Sorry to bother, but with the new version I get this error message:

B4X:
java.lang.ClassNotFoundException: flm$media$browser$MediaBrowser
    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:544)
    at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:516)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:320)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at mlc.wifitransfer.main.afterFirstLayout(main.java:91)
    at mlc.wifitransfer.main.access$100(main.java:16)
    at mlc.wifitransfer.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3691)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
    at dalvik.system.NativeStart.main(Native Method)

and the app does not start.
Are you sure that you use Java 7? Check Tools/Configure paths/javac.exe.
 

mlc

Active Member
Licensed User
Longtime User
Hi Frederic,

Sorry, you're right, I did not read the guide in the first post.

The rush is bad partner.:oops:
 

mlc

Active Member
Licensed User
Longtime User
Hi Frederic,
I get the same result with java 7

upload_2015-1-27_18-26-46.png



and the same error:

B4X:
LogCat connected to: 50D3B7A940CF533ED58A33DE39E4854
--------- beginning of /dev/log/system


--------- beginning of /dev/log/main


java.lang.ClassNotFoundException: flm$media$browser$MediaBrowser


    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:544)
    at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:516)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:320)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at mlc.wifitransfer.main.afterFirstLayout(main.java:91)
    at mlc.wifitransfer.main.access$100(main.java:16)
    at mlc.wifitransfer.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3691)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
    at dalvik.system.NativeStart.main(Native Method)


Os: windows Xp Sp2
 

mlc

Active Member
Licensed User
Longtime User
No, with my project,.
I try your demo and tell you something
 

mlc

Active Member
Licensed User
Longtime User
The error with your demo:

B4X:
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
java.lang.ClassNotFoundException: flm$media$browser$MediaBrowser
    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:544)
    at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:516)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:320)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at flm.mediabrowser.demo.main.initializeGlobals(main.java:264)
    at flm.mediabrowser.demo.main.afterFirstLayout(main.java:95)
    at flm.mediabrowser.demo.main.access$100(main.java:16)
    at flm.mediabrowser.demo.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3691)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Create, isFirst = true **
java.lang.RuntimeException: Unexpected command: 97
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:373)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at flm.mediabrowser.demo.main.afterFirstLayout(main.java:98)
    at flm.mediabrowser.demo.main.access$100(main.java:16)
    at flm.mediabrowser.demo.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3691)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
    at dalvik.system.NativeStart.main(Native Method)
 

Informatix

Expert
Licensed User
Longtime User
The error with your demo:

B4X:
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
java.lang.ClassNotFoundException: flm$media$browser$MediaBrowser
    at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:544)
    at anywheresoftware.b4a.shell.Shell.createObject(Shell.java:516)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:320)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at flm.mediabrowser.demo.main.initializeGlobals(main.java:264)
    at flm.mediabrowser.demo.main.afterFirstLayout(main.java:95)
    at flm.mediabrowser.demo.main.access$100(main.java:16)
    at flm.mediabrowser.demo.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3691)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (main) Create, isFirst = true **
java.lang.RuntimeException: Unexpected command: 97
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:373)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at flm.mediabrowser.demo.main.afterFirstLayout(main.java:98)
    at flm.mediabrowser.demo.main.access$100(main.java:16)
    at flm.mediabrowser.demo.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3691)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
    at dalvik.system.NativeStart.main(Native Method)
So ask Erel because something is wrong with your installation.
 

mlc

Active Member
Licensed User
Longtime User
I'll install the version 4.00, maybe solve the problem.
Now i have 3.80.
 

mlc

Active Member
Licensed User
Longtime User
Hello Frederic,
With the new version of B4a (4.00), i can compile the project without problems, but GetImageFileInfoByID and GetVideoFileInfoByID still does not work.

This is the error:

B4X:
Error occurred on line: 266 (serverservice)
java.lang.IllegalStateException: get field slot from row 0 col -1 failed

    at android.database.CursorWindow.getString_native(Native Method)
    at android.database.CursorWindow.getString(CursorWindow.java:329)
    at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
    at android.database.CursorWrapper.getString(CursorWrapper.java:135)
    at flm.media.browser.MediaBrowser.CommonAudioSub(MediaBrowser.java:65)
    at flm.media.browser.MediaBrowser.GetVideoFileInfoByID(MediaBrowser.java:469)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
    at anywheresoftware.b4a.objects.Servlet$2.run(Servlet.java:87)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3691)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (http) Pause, UserClosed = false **


In the fifth line I see something strange for me : at flm.media.browser.MediaBrowser.CommonAudioSub(MediaBrowser.java:65)
I have no idea, but maybe should be: CommonVideoSub
Same for images?
Thanks
 

Informatix

Expert
Licensed User
Longtime User
Hello Frederic,
With the new version of B4a (4.00), i can compile the project without problems, but GetImageFileInfoByID and GetVideoFileInfoByID still does not work.

This is the error:

B4X:
Error occurred on line: 266 (serverservice)
java.lang.IllegalStateException: get field slot from row 0 col -1 failed

    at android.database.CursorWindow.getString_native(Native Method)
    at android.database.CursorWindow.getString(CursorWindow.java:329)
    at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:49)
    at android.database.CursorWrapper.getString(CursorWrapper.java:135)
    at flm.media.browser.MediaBrowser.CommonAudioSub(MediaBrowser.java:65)
    at flm.media.browser.MediaBrowser.GetVideoFileInfoByID(MediaBrowser.java:469)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:636)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:302)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:238)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:121)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:159)
    at anywheresoftware.b4a.objects.Servlet$2.run(Servlet.java:87)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3691)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
    at dalvik.system.NativeStart.main(Native Method)
** Activity (http) Pause, UserClosed = false **


In the fifth line I see something strange for me : at flm.media.browser.MediaBrowser.CommonAudioSub(MediaBrowser.java:65)
I have no idea, but maybe should be: CommonVideoSub
Same for images?
Thanks
Fixed. Sorry for my mistakes.
 

mlc

Active Member
Licensed User
Longtime User
Hello Frederic,

I am trying to use GetExtImageFileInfo and GetExtVideoFileInfo with this code:

B4X:
Dim extt As String = "/mnt/sdcard/external_sd/dcim/Camera/20141231_235818.jpg"
Dim m As Map
m = MB.GetExtImageFileInfo(extt)

The file exists and if I use GetMediaImageList, the map returns exactly this Location, ie the extt variable.

However, GetExtImageFileInfo always returns a null map.

There's something I'm doing wrong?

Thanks
 

Informatix

Expert
Licensed User
Longtime User
Hello Frederic,

I am trying to use GetExtImageFileInfo and GetExtVideoFileInfo with this code:

B4X:
Dim extt As String = "/mnt/sdcard/external_sd/dcim/Camera/20141231_235818.jpg"
Dim m As Map
m = MB.GetExtImageFileInfo(extt)

The file exists and if I use GetMediaImageList, the map returns exactly this Location, ie the extt variable.

However, GetExtImageFileInfo always returns a null map.

There's something I'm doing wrong?

Thanks
Did you add the permission to read the SD card? (look at the manifest of my demo)
 
Top