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)...
All comments gratefully received.
Thanks,
RandomCoder
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