Android Question SMB file access or possibly HTTP?

RandomCoder

Well-Known Member
Licensed User
Longtime User
Advice needed please....

What I hope to achieve is to enable my young son to watch movies on the tablet we've bought him for Christmas. The movies are stored on a HP Micro Server running Lubuntu. Each movie is stored in its own folder containing various files related to it and set to allow shared access to other PCs. XBMC is also running on this PC. The app I intend to create needs to be able to filter out child friendly movies so that my son can select and play the ones he wants to watch.

I've used the SMB library to get a list of directories which provides me with the movie path and the movie name (folders are named according to the movie contained within). But what I now need to do is access the info stored within a text file in each folder to determine what certificate the movie is. I've searched the community and scoured the internet and it would appear as though I need to download the file to the tablet, then access the information before deleting the file. This thread suggests doing it that way http://www.b4x.com/android/forum/threads/open-file-from-network-drive.24518/#post-142100

However once I've got the info, I'll then be looking at playing the selected movie and the thought of having to download it before playing it makes me wonder if this is the right approach? After researching last night and again tonight I now wonder if using the HTTP library might me a better option? XBMC has a built-in server and so I should be able to utilise this although I've never done anything like this before.

Advice on the best way forward is really all that I'm after. Below is the code that I've done so far (adapted from the SMB tutorial code)...
B4X:
Sub Process_Globals
    Dim SMB As SMB
    Type MovieInfo(SMBPath As String, Title As String, Year As Int , Cert As String)
    Dim MovieList As List
End Sub
 
Sub Globals
 
End Sub
 
Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        ' Initialise MovieList and SMB then get files/folders from network share
        MovieList.Initialize
        SMB.Initialize("SMB")
        SMB.SetCredentials("james", "James1234","")
        SMB.ListFiles("smb://SERVER/Network Share/Movies/","")
    End If
End Sub
 
Sub SMB_ListCompleted (Url As String, Success As Boolean, SMBFiles() As SMBFile)
    If Not(Success) Then
        ' Failed to retrieve files/folders from network share
        Log(LastException)
    Else
        ' Loop through all files/folders
        For i = 0 To SMBFiles.Length - 1
            ' Only interested in folder names
            If SMBFiles(i).Directory Then
                ' Store movie info
                Dim Movie As MovieInfo
                Dim sTitle As String
                Movie.Initialize
                Movie.SMBPath = "smb://SERVER/Network Share/Movies/" & SMBFiles(i).Name
                ' Remove backslash from name for movie title
                sTitle = SMBFiles(i).Name
                Movie.Title = sTitle.SubString2(0, sTitle.Length-1)
                ' Extract year and certification from "Movie.nfo" file
                Movie.Year = 2000 + i ' #TODO get year
                Movie.Cert = "A" & i  ' #TODO get certification
                ' Add info to MovieList
                MovieList.Add(Movie)
            End If
        Next
    End If
   
    ' Following lines for testing only
    Log(MovieList.Get(0))
    Dim Movie As MovieInfo
    Movie = MovieList.Get(521)
    Log(Movie.SMBPath)
    Log(Movie.Title)
    Log(Movie.Cert)
    Log(Movie.Year)
End Sub

All comments gratefully received.

Thanks,
RandomCoder
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
Thanks for the reply Erel,
The XBMC app is just a remote control, however I believe that Yatse is a similar app that can also stream to the device. The problem is that my son would then have access to all the films, some of which are unsuitable for his age. XBMC also has full read/write access to the files and so there may be a chance that files could be accidentally deleted. The SMB route meant that I could provide read only access and filter what was available.

I must say that I was impressed at how fast it was able to retrieve over 500 directories on a wireless network!

I'll read up some more on Vitamio (only just came across this last night after posting), and I'll have a play with the HttpUttils2 library tonight if my wife allows it ;)

Kind regards,
RandomCoder
 
Upvote 0

sorheim

Member
Licensed User
Longtime User
Hello,

I have a similar setup and found it quite easy to mange with existing apps. I have two folders shared on a windows box one with pg13 an up and another with kids movies. I use exfile explorer to set up a link to the shared kids movie folder on the kids tablet. I use vplayer or mxplayer and both stream most movies quite well on my home network.

Regards,

Scott
 
Upvote 0

RandomCoder

Well-Known Member
Licensed User
Longtime User
Thanks for the reply Scott.
Whilst searching for ways to do this I've come across the XBMC app for Android. It's not available in Google play and so I wasn't aware of it before. It is however excellent and exactly like the PC version.
I'm still trying to experiment with B4A and was very impressed with how fast the SMB file/folder listing was. My biggest problem is finding the time to experiment whilst also searching the web for ideas.

Cheers,
RandomCoder
 
Upvote 0
Top