Android Question SimpleMediaManager - Get images from local storage

John Naylor

Active Member
Licensed User
Longtime User
I have a folder [XUI.DefaultFolder]/original which contains several jpg images. (1.jpg, 2.jpg.....etc)

Is it possible with SimpleMediaManager to load those images to be displayed?

Something like

B4X:
MediaManager.SetMedia(pnl.GetView(x).GetView(0), GetURL(data.IndexOfFirstImage + x) & ".jpg")

then

B4X:
Sub GetURL (FileName As String) As String
    Dim r As String = "file://" & xui.DefaultFolder & "/original/" & FileName
    Return r
End Sub

which gives the error - Invalid link: file:///storage/emulated/0/Android/data/b4a.example/files/original/1.jpg (and 2.jpg etc).

[edit] I guess I could make an httpserver on the device and send the images via that but it seems excessive?
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Assuming that there aren't too many images, you can add all of them with AddLocalMedia:
B4X:
For Each f As String In Array("image1.png", "image2.png", ...)
 MediaManager.AddLocalMedia(f, xui.LoadBitmap(XUI.DefaultFolder, f), "image/*") 'first parameter is the 'key'.
Next

MediaManager.SetMedia(Panel1, "image2.png")
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
Assuming that there aren't too many images, you can add all of them with AddLocalMedia:
B4X:
For Each f As String In Array("image1.png", "image2.png", ...)
 MediaManager.AddLocalMedia(f, xui.LoadBitmap(XUI.DefaultFolder, f), "image/*") 'first parameter is the 'key'.
Next

MediaManager.SetMedia(Panel1, "image2.png")
How many would you consider 'not too many'? - I may have 1000+ images at the upper end of my scale. Would creating thumbnails and displaying those help much in such a scenario?

Given the cache won't be cleared when using AddLocalMedia I was favouring a more dynamic approach.

Either way SMM is a superb library!
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
All I can say is WOW!!!!

MediaManager.SetMediaFromFile works like a charm for me!

As has been said before @Erel you are one certifiable utter genius! Thank you so very much!
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
Well it's just speeded up what I'm doing vastly - my app gets sent images via FTP from one or more DSLR cameras where they are renamed, manipulated (temperature, saturation, hue etc) to the photographers selected presets, then uploaded again to preset ftp servers or my B4J web app which can display them using specific codes generated by whatever event is being shot. I now have a superb camera roll under whatever photo is selected so the photographer can easily select individual images to upload, delete, modify further etc.

Incredible work, I cannot thank you enough!
 
Upvote 0
Top