Android Question Simple Media Manager : timeout or black screen

CR95

Active Member
Licensed User
I slightly modified B4A SMM Example1 to connect it to a Web Socket Server developed with B4J and running on RaspBerry.

I get an error when trying to display huge video files on the Android phone (see below).

Logger connecté à : Xiaomi Redmi Note 5

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
RegisterForMeta: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4
AddMedia: ~loading
Creating view: ~loading, type: Panel
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:
MetaIsReady: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4, MediaCache contains? false, ~unknown
TrimMediaCache: 3
AddMedia: ~error
ReturnViewToCache: ~loading
Reusing view: (Panel) ~loading -> ~error
Removing media with error: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4
Removing meta with error: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4

I saw that a modification was made on March
 

CR95

Active Member
Licensed User
Sorry for the trouble : I sent previous message before terminating

I slightly modified B4A SMM Example1 to connect it to a Web Socket Server developed with B4J and running on RaspBerry.

It works fine with small size videos but I get an error when trying to display huge video files on the Android phone (see below).

Logger connecté à : Xiaomi Redmi Note 5

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
RegisterForMeta: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4
AddMedia: ~loading
Creating view: ~loading, type: Panel
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.SocketTimeoutException: timeout, Response:
MetaIsReady: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4, MediaCache contains? false, ~unknown
TrimMediaCache: 3
AddMedia: ~error
ReturnViewToCache: ~loading
Reusing view: (Panel) ~loading -> ~error
Removing media with error: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4
Removing meta with error: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4
Click to expand...
I saw that a modification was made in SMM library on March,6 to adapt DefaultRequestTimeout field -> I am using SMM library 1.12 with this modification.

All the video files that are "time out" with SMM start immediatly when launched from phone Android browser (same hardware, same server, same communication way)

In some cases, this is not a timeout error but video does not start and screen remains black.

Is there a solution for this kind of issue ?
 
Upvote 0

CR95

Active Member
Licensed User
Thanks Erel.
As you advise, I tried to add the timeout value in SMM_Example1 program BUT I discovered that my SMM library is not at the latest level. Please see joined picture.

I am sure that I downloaded and that I copied in my internal libraries the latest version from :
https://www.b4x.com/android/forum/t...-framework-for-images-videos-and-more.134716/

I guess that "your" timeout modification is usable only with the 1.12 version
Please could you help
 

Attachments

  • SMMPbme.png
    SMMPbme.png
    91 KB · Views: 165
Upvote 0

CR95

Active Member
Licensed User
Thanks, DonManfred,
I upgraded to B4A.11.5 and SMM library level is now correct (1.12)
I made a test with a long video file BUT it crashes as timeout is still 30 seconds.
I suppose that my declaration to increase it is not correct (in Sub Class_Globals of B4XMainPage)
B4X:
Public DefaultRequestTimeout As Int = 10 * 60 * 1000 '10 minutes
In Erel's code, there was SMM before the declaration (SMM.DefaultRequestTimeout = 10 * 60 * 1000 '10 minutes)
What am I doing wrong ?
Thanks for helping,
 
Upvote 0

CR95

Active Member
Licensed User
This is OK : with the 10 minutes TimeOut setting, it works

But "loading time" (waiting time) is more than 1 minute 10 seconds.
Same video loaded by browser starts after 2/3 seconds

SMM is really powerful, but is there a way to reduce this "loading time", knowing that I modify this file in order to have metadata ("mdat" atom and "moov" atom) at the beginning of the video file ?
(It is recommended that MPEG-4 media to be played over HTTP be formatted such that the headers required to decode the stream appear at the beginning of the file.)

Thanks
 
Upvote 0

CR95

Active Member
Licensed User
Thanks Erel,

I made a direct loading with ExoPlayer only and.... the video file starts after 1 second !

So the timeout issue is somewhere between SMMExample1 <-> SMMMedia <-> ExoPlayer !

May be if you tell me where I can load the class with SMMMedia, I could insert it in the SMM Example1. Then by adding some time tracing at different places, it could be possible to find which module is responsible for the timeout ????
 
Upvote 0

CR95

Active Member
Licensed User
@Omar Parra A.
I already set the DefaultRequestTimeout to 10 minuts
1 added MediaManager.SleepDurationBeforeDownload = 0
Loading time does not change (> 1 minut)

@Erel
Yes SMMDebug was set.
Following is the Log
I also logged the time when launching SMM request (15:53:11) and the time when starting the video on the phone (15:54:25)

Logger connecté à : Xiaomi Redmi Note 5
--------- beginning of system
--------- beginning of main
Copying updated assets files (3)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Launch Time= 15:53:11
RegisterForMeta: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4
AddMedia: ~loading
Creating view: ~loading, type: Panel
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
MetaIsReady: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4, MediaCache contains? false, video/mp4
TrimMediaCache: 3
AddMedia: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4
ReturnViewToCache: ~loading
Creating view: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4, type: video player
Starting Time= 15:54:25

I don't understand "mark the timings" as you requested
Thanks for helping
 
Upvote 0

CR95

Active Member
Licensed User
@Erel
Yes, it "pauses" for more than 1 minute..
I added the SMM library classes inside the SMMExample1 B4A program and I added time tracing after some Logs in these classes.
Result is below. For me, time is "lost" between "Creating view" (11:25:00) and "MediaIsReady" (11:26:13)
What can I do for helping you ?
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
B4A Launch Time= 11:24:59
SMM SetMediaWithRequestSet Time= 11:24:59
RegisterForMeta: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4
SMM RegisterForMeta Time= 11:24:59
AddMedia: ~loading
SMMViews AddMedia Time= 11:25:00
Creating view: ~loading, type: Panel
SMMViews Creating view Time= 11:25:00
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
MetaIsReady: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4, MediaCache contains? false, video/mp4
SMM MetaIsReady Time= 11:26:13
TrimMediaCache: 3
SMM TrimMedia Time= 11:26:13
SMM MetaIsReady Time= 11:26:13
AddMedia: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4
SMMViews AddMedia Time= 11:26:13
ReturnViewToCache: ~loading
SMMViews Time= 11:26:13
Creating view: http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4, type: video player
SMMViews Creating view Time= 11:26:13
B4A Playing Time= 11:26:14
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I think that I know what happens. The HEAD request isn't handled properly by the server which returns the full video file.

Please try this:
B4X:
Dim url As String = "http://192.168.1.165:51042/CRvideos/Videos2000/ToutRoumanie2.mp4"
SMM.AddLocalMedia(url, url, "video/mp4")
'now call SMM.SetMedia
 
Last edited:
Upvote 0

CR95

Active Member
Licensed User
Bingo. It starts immediatly.
There is a typo error -> AddLocalMedia
Will this "add-on" be integrated in a future version of the library ?
Thanks for helping -> I send you a small contribution
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Will this "add-on" be integrated in a future version of the library ?
SMM relies on the HEAD request. Without it, it cannot properly handle different types of medias.

I missed the fact that you are using a B4J server. A better fix will be to find out why it returned the media itself for a HEAD request.
 
Upvote 0

CR95

Active Member
Licensed User
Yes, I am using a B4J Web Socket Server.
My whole project is called "memory" ; it is made only with B4X pieces. As I am 72 old, my purpose is to save all my MP3, personal videos and photos on a large disk connected to a Raspberry with a Linux server. Then, it is possible to simply hear/show them on phones. Database is useful for perrmitting to sort (thousands of) elements (by artist for MP3, by year or by geographic place for videos, etc...)

MonProjet.png


Next step is to integrate the memory server with a second server which controls home cinema equipments and to get the same "delivery service" on home TV or sound system.
 
Upvote 0
Top