Click here to Skip to main content
11,704,107 members (63,611 online)
Rate this: bad
good
Please Sign up or sign in to vote.
How do I force VLC in VB.NET to buffer before playing? Any help would be amazing

Basically videos play well but at times videos will stop randomly and I don't know how to allow for proper buffering which would help tremendously.


Could someone please tell me howto do this

Code so far:

Imports System.Text.RegularExpressions
 
   Public Class Form1
       Dim Paused As Boolean = False
       Dim Started As Boolean = False
       Dim PlayedSecond As Boolean = True
       Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
           PlayedSecond = False
           AxVLCPlugin21.playlist.items.clear()
           AxVLCPlugin21.playlist.add("http://binder-science.wikispaces.com/file/view/The+Characteristics+of+Living+Things.flv")
           AxVLCPlugin21.playlist.play()
           Started = True
       End Sub
 
       Sub playsecond()
           AxVLCPlugin21.playlist.items.clear()
           AxVLCPlugin21.playlist.add("http://postfcs.wikispaces.com/file/view/Nature+by+Numbers+%5Bwww.keepvid.com%5D.flv")
           AxVLCPlugin21.playlist.play()
           PlayedSecond = True
           Started = False
       End Sub
 
       Private Sub AxVLCPlugin21_pause(sender As Object, e As EventArgs) Handles AxVLCPlugin21.pause
           Paused = True
       End Sub
 
       Private Sub IsFinished_Tick(sender As Object, e As EventArgs) Handles IsFinished.Tick
           If Not AxVLCPlugin21.playlist.isPlaying And Paused = False And Started = True And PlayedSecond = False Then
               playsecond()
               Started = True
           End If
       End Sub
 
       Private Sub AxVLCPlugin21_play(sender As Object, e As EventArgs) Handles AxVLCPlugin21.play
           Paused = False
       End Sub
 
       Private Enum InputState
           IDLE = 0
           OPENING = 1
           BUFFERING = 2
           PLAYING = 3
           PAUSED = 4
           STOPPING = 5
           ENDED = 6
           ERRORSTATE = 7
       End Enum
 

       Private Sub InfoTimer_Tick(sender As Object, e As EventArgs) Handles InfoTimer.Tick
           Dim state As InputState = DirectCast(AxVLCPlugin21.input.state, InputState)
           Select Case state
               Case InputState.IDLE, InputState.OPENING, InputState.BUFFERING
                   Status.Text = state.ToString()
                   Exit Select
               Case InputState.PLAYING
                   Dim title As String = System.IO.Path.GetFileName(AxVLCPlugin21.mediaDescription.title)
                   Dim current As TimeSpan = TimeSpan.FromMilliseconds(AxVLCPlugin21.input.Time)
                   Dim total As TimeSpan = TimeSpan.FromMilliseconds(AxVLCPlugin21.input.Length)
                   Dim pos As Double = AxVLCPlugin21.input.Position
                   Status.Text = String.Format("{0} {1} {2}:{3:D2}/{4}:{5:D2} {6:P}", state, title, current.Minutes, current.Seconds, total.Minutes, total.Seconds, pos)
                   Exit Select
               Case InputState.PAUSED
                   Status.Text = String.Format("{0} {1}", state, System.IO.Path.GetFileName(AxVLCPlugin21.mediaDescription.title))
                   Exit Select
               Case InputState.STOPPING, InputState.ENDED
                   playsecond()
                   Exit Select
               Case InputState.ERRORSTATE
                   Status.Text = String.Format("{0} {1}", state, AxVLCPlugin21.mediaDescription.title)
                   Exit Select
               Case Else
                   Status.Text = state.ToString()
                   Exit Select
           End Select
       End Sub
 
   End Class
Posted 3-Feb-13 3:37am
Comments
Member 8620581 at 3-Feb-13 10:47am
   
Why do you wanna buffer ?

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Buffering can be increased by specifying options in the play list. Although you can test various sizes in the plugin I find it easier and quicker in the VLC player. Just check "Show more options" in the OpenMedia dialog, and adjust the cache value UpDown control.

Private Sub LoadBufferedUrl()
  Const TestUrl As String = "http://binder-science.wikispaces.com/file/view/The+Characteristics+of+Living+Things.flv"
  ' Buffer 10 seconds
  Dim Options As String() = New String() {":network-caching=10000"}
  AxVLCPlugin21.playlist.add(TestUrl, Nothing, Options)
End Sub
As before this has been converted from C# so I hope it's OK.

Other options can be specified, but I have not been able to find a list of which VLC player options are operational in the plugin. Many are not and these are the few I can vouch for:
:file-caching=2100	Approximate cache size in milliseconds (max 60,000)
:network-caching=3000	Approximate cache size in milliseconds (max 60,000)
:start-time=60.0	Start playing position (seconds). 
                        This is inaccurate on some file types, e.g. mpeg2, 
                        probably due to variable bit rate and lack of indexing.
:stop-time=120.0	Stop playing position (seconds).  This is accurate
:input-repeat=N	        Repeat N times (play N+1 times)
:run-time=30.0	        Play for a maximum of this duration (seconds)

Examples
Play first 10 seconds, 4 times
Dim Options As String() = New String() {":input-repeat=3", ":run-time=10.0"}
Play from 10 to 20 seconds
Dim Options As String() = New String() {":start-time=10.0", ":run-time=10.0" }
or this would do the same
Dim Options As String() = New String() {":start-time=10.0", ":stop-time=20.0" }

Alan.
  Permalink  
Comments
Andrew Smith at 3-Feb-13 14:00pm
   
Thank you so much. I've been looking for help on this everywhere with no luck :-) Have a great night mate.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 745
1 OriginalGriff 520
2 Maciej Los 475
3 Andy Lanng 284
4 CPallini 275
0 OriginalGriff 8,784
1 Sergey Alexandrovich Kryukov 7,843
2 CPallini 5,107
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100