Problem playing multiple videos with videoview

CodeDancer

Member
Licensed User
Longtime User
When I attempt to play more than one video, the first plays then I get a blank screen. The following videos will show if I touch the blank screen though.

Sub PlayVideo
Dim VideoName As String

Select Case Video
Case 1
vv.Initialize("vv")
vv.MediaControllerEnabled = False
Activity.AddView(vv, 10dip, 10dip, stpanel.Width , stpanel.Height )
VideoName = "Spiral.mp4"
Case 2 : VideoName = "SpiralHypno.mp4"
Case 3 : VideoName = "Star.mp4"
Case 4 : Exit
End Select

vv.LoadVideo(File.DirRootExternal, "/Media/Video/" & VideoName)
' File.DirRootExternal = /mnt/sdcard
vv.Play
End Sub

Sub vv_Complete 'Playing completed
If video<3 Then
Video=Video+1
PlayVideo
End If
End Sub

Any ideas, anyone?
 

CodeDancer

Member
Licensed User
Longtime User
After much fiddling with the code, I resolved the problem or got it to work at least.

It appears that you have to initialize videoview again for each new video you want to play. So you have to remove the last view, re-initialize, then add the new view. Not very elegant, but the only solution that I could find.

B4X:
Sub PlayVideo
  Dim VideoName As String 
  
  Select Case Video
  Case 1 : VideoName = "Spiral.mp4"
  Case 2 : VideoName = "SpiralHypno.mp4"
  Case 3 : VideoName = "Star.mp4"
  End Select
  
  If vv.isinitialized = True Then vv.RemoveView 
  vv.Initialize("vv")
  vv.MediaControllerEnabled  = False
  Activity.AddView(vv, 10dip, 10dip, stpanel.Width , stpanel.Height )
  vv.LoadVideo(File.DirRootExternal, "/Media/Video/" & VideoName)
' File.DirRootExternal = /mnt/sdcard
  DoEvents
  DoEvents
  vv.Play
End Sub

Sub vv_Complete 'Playing completed
  If Video<3 Then
    Video=Video+1
   PlayVideo
  End If
End Sub

Thanks for the heads up, Erel. I was trying to figure out how to get one of those nice little scrolling code boxes.
 
Upvote 0

Arun

Member
Licensed User
Longtime User
Problem playing multiple Videos with VideoView/VideoViewExt - not working

Hi Erel,

I am having exactly the same problem and modified my code as per the working solution given by CodeDancer in Post #3. :BangHead:

Check the unfiltered logs. There might be related messages. You can use a timer to add a short delay between the complete event and the next play.

I tried a timer for upto 5 secs between videos, as per your suggestion above, but it is still not working. :BangHead:

I went through the log, but there is a difference in what is logged and what the screen actually displays. Also, I admit I did not really understand the finer details. :BangHead:

I have attached the unfiltered log with my notes as to what is actually visible on the screen.

Please go through the attached log, if it is not too much trouble, and give me some explanation on how to rectify this problem.

FYI, I have tried VideoView and VideoViewExt, but no difference. :BangHead:

I am using b4a 2.3 and 7" tablet with ICS.

Thanks a lot.

Arun

Edit: The video can be heard although the screen is black/blank, so I know the video is playing, just not visible.
 

Attachments

  • VideoViewBlackScreenLog.txt
    11.3 KB · Views: 338
Last edited:
Upvote 0

Arun

Member
Licensed User
Longtime User
Hi!

@Erel
My first statement was that I tried CodeDancer's solution (Remove, re-initialize, add). In fact, when I saw this thread, it gave me hope because I found someone facing the same problem I was. I had originally done it only once in the beginning.

Since that did not work, I tried your suggestion of a timer. That too did not work.

You also suggested to check the logs. That's the reason I attached the logs here, hoping it would give you (and you could give me) some hint.

@CodeDancer
Yes - I have dimmed VideoView in Globals
My playlist files are read in from a file and stored in a listview. At the end of the listview, i read the file again. The counters (Video in your case) are ok.

I have implemented Margret's class. Also, the activity is Full Screen/Landscape only.

The program is working perfectly. I can hear the video so I know it is playing, it just does not show on screen till I touch it or after some duration. (5 to 30+ seconds).

Any other suggestions?

Thanks in advance.

Arun
 
Upvote 0

CodeDancer

Member
Licensed User
Longtime User
To Arun

I was not overly happy having to use a "brute force" approach to get around what is probably a B4A bug in Videoview causing the view to lose focus between videos.

The code I posted works perfectly on my 2.2.1 and 4.0.3 tablets. I noticed that you are using B4A version 2.3. I am still at 2.22. Could be a problem?

Have you tried running the code on a simulator? If you want to zip your code and a couple of videos I could try it out, but I don't know exactly where that would get us.

Time to call on the heavy hitters. See if we can at least get it onto the bug list.
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
I use VideoView all the time in a few apps and have never had any issue changing videos. I only dim and initialize the view once. What I do is in the sub where I load a video, it starts a timer to check every second the vv.duration. If you issue a vv.play before the vv.duration is > 0, then nothing will happen. Different devices take different amounts of time, so a delay will not always work. The sub is listed below:

B4X:
Sub StartVideo_Tick
     If vv.Duration > 0 Then
          StartVideo.Enabled = False 'Stop the timer
          vv.Play
     End If   
End Sub
 
Last edited:
Upvote 0

CodeDancer

Member
Licensed User
Longtime User
To Margret

Maybe you were just lucky. I replaced vv.play with StartVideo.enabled = true and tried the timer approach. It was back to square one. The first video shows then you get a blank screen for the rest. Viewable only by touching the screen.
 
Upvote 0

CodeDancer

Member
Licensed User
Longtime User
To Margret

Actually, we might be both correct about the luck factor.
I suggest that you read the thread by Robotop entitled "Troubles Playing Videos On Chinese Export Tablets. That could be your good luck and my bad.

Here's some simple code that I suspect will work on your machine but not on mine. Arun's machine may be even worse off.
You can send me something that works on your machine to verify this. I couldn't upload the video zip file, since it is way more than 390.6 K but I can email it to you, if you want.

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application     starts.
   'These variables can be accessed from all modules.
   Dim StartVideo As Timer 
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

   Dim cnv As Canvas
   Dim stpanel As Panel
     Dim xcenter,ycenter As Int     
   Dim lv As LayoutValues   
   
   Dim vv As VideoView
   Dim Video As Int
   Dim PlayStart As Long 
   Dim Picture As Int
   Dim IV As ImageView 
    
        Dim mc As Controls
   
   
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
      Activity.LoadLayout("starscroll")   'nothing special just stpanel + exitbtn  
      
      lv = GetDeviceLayoutValues
      
      ' resize panel
      stpanel.Width = lv.Width 
      stpanel.height= lv.Height 
      
      cnv.Initialize(stpanel)
        mc.Initialize(Activity, Me)

      xcenter = stpanel.Width / 2
       ycenter = stpanel.Height / 2
        
        mc.NavBarOff' mc.NavBarOn
       mc.ActionBarOff ' mc.ActionBarOn
      
      If FirstTime = True Then
          StartVideo.Initialize("StartVideo", 1000)
        StartVideo.Enabled =False
        End If
      
 '      ShowPictures
       Video=1
       PlayStart=DateTime.Now 
       PlayVideo
      
End Sub


Sub Activity_Resume
 ' Video=1
'  PlayVideo
End Sub

Sub Activity_Pause (UserClosed As Boolean)
  
End Sub

Sub PlayVideo
  Dim VideoName As String 
  
'  FullScreen(True,"Main" )
  
  Select Case Video
  Case 1 :
    VideoName = "Iris.avi"
    vv.Initialize("vv")
    vv.MediaControllerEnabled  = False
    Activity.AddView(vv, 0, 0, 640 , 480 )
   vv.SetLayout (0,0,stpanel.Width*4,stpanel.Height*4)'Top,Left,Width,Height
  Case 2 : VideoName = "Spiral.mp4"
  Case 3 : VideoName = "Star.mp4"
  Case 4 : VideoName = "Swirl1.avi"
  Case 5 : VideoName = "Swirl2.mp4"
  Case 6 : VideoName = "WindMill.avi"
  Case 7 : VideoName = "WindMill2.avi"
  Case 8 : VideoName = "WindMill3.avi"
  Case 9 : VideoName = "WindMill4.avi"
  Case 10 : VideoName = "PsychoSpin.mp4"
  End Select
  
'  If vv.isinitialized = True Then vv.RemoveView 
  vv.LoadVideo(File.DirRootExternal, "/Media/Video/" & VideoName)
' File.DirRootExternal = /mnt/sdcard
  
  StartVideo.Enabled =True
  
End Sub

Sub vv_Complete 'Playing completed
  If Video<10 Then
    Video=Video+1
  Else
    Video=1
  End If
  If (DateTime.Now - PlayStart) < 120000 Then 
    PlayVideo   
  Else
    If Video<>1 Then
     PlayVideo   
   Else
     ExitApplication
   End If
  End If
  
End Sub

Sub StartVideo_Tick
  If vv.Duration > 0 Then
    StartVideo.Enabled = False
    vv.Play
  End If    
End Sub
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
You did not send me your complete project. The Layout file and anything else you had in the assets folder was missing. So, I just changed the code to run without the other stuff. This code runs fine and starts the next video like it should. I also added some logging so you can see the logs when it's running. Let us know what happens with this code. Run it just as it is first before you try to add the other code back in and see if it works.
 

Attachments

  • VideoTest.zip
    6.9 KB · Views: 267
Upvote 0

CodeDancer

Member
Licensed User
Longtime User
To Margret

It doesn't show any videos after the first, except for an occasional frame.
I tried to match the info in the log you sent me, but as you know, the logs are kind of cryptic to Android newcomers. So I attached the complete log. (Please don't hate me)

I have the sinking feeling that this problem is a device dependent B4A bug that probably will never be resolved unless the log gives you something useful.

BTW, I am curious why you moved your timer dim from process_globals to globals, forcing restarts.

I really appreciate your help, so far.
 

Attachments

  • Chinese.zip
    20.2 KB · Views: 259
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
Hello,

The logs you sent show a loaded duration for all videos. You should of selected the [Filter] checkbox for the logs. That way it will be showing info on your app. However, in the logs I see where the media process is failing and reloading. This is not a B4A issue but an issue of the OS. I also see native resolutions of the video containers and some are full HD and this may explain your seeing a frame or two here and there. Does you device even support full HD play back?? Run the test app again and this time do Filter logs and it will be much easier for you to see what's going on. Then post or ZIP the filter logs for me to see. Also, the movies you are trying to play, try and play each one in the default player(not B4A) on the device and see which ones will play and which ones will not. This is a good place to start. Once you do this post again and we will see if we can find out what's going on.
 
Upvote 0

CodeDancer

Member
Licensed User
Longtime User
Hi Margret

The reason I didn't send you the unfiltered log is that it didn't seem to indicate any problems. I am attaching two, this time. One was your code unchanged and the second was after I moved the timer dim back to process_globals so it would cycle through the videos a couple of times, like it was supposed to. That's why I asked.

The videos work fine on my tablet video viewers and also under B4A with the brute force re-initialization modification. I don't think that they are the problem.
I am quite sure that the videos are playing with your code too. The videoview simply isn't visible and I've tried every trick I could think of to wake it up.

I agree that we appear to have a B4A to Chinese OS interface problem. That would explain losing the screen and being unable to bring it back without re-initializing the videoview.

There appears to be a timing aspect to this problem also. I tried to incorporate your timer into my brute force solution and it stopped working correctly. Just showed the first video etc.

I know that there are a lot of tablets like mine on the market and I wonder
how many other B4A users are experiencing graphics problems. I noticed that our thread is getting a few views.

Happy Holidays!
 

Attachments

  • ChineseGlobals.log.txt
    2.8 KB · Views: 290
  • ChineseProcessGlobals.log.txt
    3.3 KB · Views: 322
Upvote 0

Arun

Member
Licensed User
Longtime User
Hi,

Sorry for not taking part in this discussion but I needed a weekend break after running around like a headless chicken with this problem.

I wanted to check if the problem was with the device, so I am trying to figure out how to run the app on my Samsung phone which has 2.3.6. I did try this initially, but my app had not worked. I posted a question at the time, but did not get a reply and did not follow it up. Now, I am trolling the forum to figure out how to do it.

Just for info, I am developing this app for a school, where they want to run some videos and give links to restricted websites. Control of the tab is not to be given to the students. So the mentality - if a tab available for less than USD 100 does the work, why spend 10 times for a branded device!

I will try all the suggestions in this thread in a couple of days and post my findings.

Thanks a lot and wishing everyone a Merry Christmas!

Arun
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…