VideoView ALWAYS works on 1st play, but not afterwards

joolzg

Member
Licensed User
Longtime User
OK been playing with this for just under a week and still have not got it to play videos properly in full screen.

What I have found is when i run my app for the 1st time i ALWAYS get a full screen picture, its only when i try to change the stream to another one it fails.

I have check over 50 channels, 50 restarts and always i get the right video size.

So my init code

B4X:
Sub Globals
    ...
    Dim vv As VideoView
    ...
End Sub

B4X:
Sub Activity_Create(FirstTime As Boolean)
    ...
 vv.Initialize( "vv")
 Activity.AddView( vv, 0, 0, Activity.Width, Activity.Height)
End Sub

then my change streams

B4X:
   If vv.IsPlaying Then
      vv.Stop
   End If
   If show Then
      ShowChannelInfo
   End If
   If cCurrent.cRadio Then
      vv.SetBackgroundImage( radioBackground)
   Else
      vv.SetBackgroundImage( Null)
   End If
   vv.LoadVideo( "http", cCurrent.cUrl)
   vv.MediaControllerEnabled = cCurrent.cVOD

So I was wondering is there a way to delete the vv object and do a vv.initialise every channel change

joolz
 

margret

Well-Known Member
Licensed User
Longtime User
I have had to do this on some of my apps. When you change channels and load the new channel, you need about a half second timer that reloads the new channel and it will then load the correct size. So, you are loading and then reloading the new channel a half second between them. This is an issue in the Android VV. It is corrected I have found in ICS.
 
Upvote 0

joolzg

Member
Licensed User
Longtime User
Thanks for the info.

Have you a demo as ive tried adding thr .5 second and still seeing the same problem, or where to insert the delay.

between the vv.LoadVideo and vv.Play ?

joolz
 
Upvote 0

joolzg

Member
Licensed User
Longtime User
OK done what you said and this is my log out, time in ticks for

vv.LoadVideo
StartLoading #Test TG4
StartLoading Ticks:1334692565493
vv.Play
StartPlaying Ticks:1334692565503
StartLoading #Test TG4
vv.LoadVideo
StartLoading Ticks:1334692566013


vv.LoadVideo
StartLoading #Test TV3 (Ireland)
StartLoading Ticks:1334692596982
vv.Start
StartPlaying Ticks:1334692596992
vv.LoadVideo
StartLoading #Test TV3 (Ireland)
StartLoading Ticks:1334692597493

Any more ideas? please

joolz
 
Upvote 0

joolzg

Member
Licensed User
Longtime User
B4X:
Sub StartStreaming( show As Boolean)
   If vv.IsPlaying Then
      vv.Stop
   End If
   If show Then
      ShowChannelInfo
   End If
   If cCurrent.cRadio Then
      vv.SetBackgroundImage( radioBackground)
   Else
      vv.SetBackgroundImage( Null)
   End If
   vv.MediaControllerEnabled = cCurrent.cVOD
   Log( "StartLoading " & cCurrent.cTitle)
   Log( "StartLoading Ticks:" & DateTime.Now)
   vv.LoadVideo( "http", cCurrent.cUrl)
   Log( "StartPlaying Ticks:" & DateTime.Now)
   vv.Play
   playTimer.Interval = 500
   playTimer.Enabled = True
End Sub

Sub Activity_Create(FirstTime As Boolean)
...
      playTimer.Initialize( "playtimer", 500)
...
End Sub

Sub playtimer_Tick
   playTimer.Enabled = False
   Log( "StartLoading " & cCurrent.cTitle)
   Log( "StartLoading Ticks:" & DateTime.Now)
   vv.LoadVideo( "http", cCurrent.cUrl)
End Sub
 
Upvote 0

margret

Well-Known Member
Licensed User
Longtime User
OK, change the timer from 500 to 1000, if that don't work, change it to 2000 or more just for a test. It may be that your connection can not provide the data fast enough with the timer set to 500. You should see the video start playing, go blank for a split second and then start playing again. Let me know if this makes a difference.
 
Upvote 0

joolzg

Member
Licensed User
Longtime User
Here a demo file, can you get it working?

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.

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 vv As VideoView
   Dim tt As Timer
   Dim video As Boolean
End Sub

Sub Activity_Create(FirstTime As Boolean)
   vv.Initialize( "vv")
   Activity.AddView( vv, 0, 0, 100%x, 100%y)
   tt.Initialize( "tt", 10000)
   tt_Tick
   tt.Enabled = True
End Sub

Sub tt_Tick
   vv.Stop
   If video Then
      vv.LoadVideo( "http", "http://02.spain.unistream.tv:4444/udp/239.100.200.1:1234")
   Else
      vv.LoadVideo( "http", "http://02.spain.unistream.tv:4444/udp/239.100.200.2:1234")
   End If
   vv.Play
   video = Not( video)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Ive tried from 10 seconds down

http://www.sendspace.com/file/psfvtu

joolz
 
Last edited:
Upvote 0

joolzg

Member
Licensed User
Longtime User
Got it working !!!!!!!!!

What i had to do was

vv.RemoveView
vv.Initailize( "vv")

before every stream change and it works perfectly

has a few problems with OSD but thanks to NJDUDE and tds this was fixed

joolz
 
Upvote 0

joolzg

Member
Licensed User
Longtime User
on a website in spain, they offered a demo of CNN, and when i saw the url i just changed the end address to 1 and hey free channels, you can use from 1 to 33 i think

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