mobileFX WebKitX CEF3 ActiveX 4.x
WebKitXCEF3Lib ActiveX Control / WebKitXCEF3 Object / PlayHLS Method

The CSS3 Selector of the VIDEO element to attach HLS.js. If set to "_new", a new VIDEO element will be used.

If you are unfamiliar with CSS3 Selectors have a look in Finding the correct CSS3 Selector article.

The HTTP Live Stream URL to play.

The HTTP Live Stream options object.

In This Topic
    PlayHLS Method
    In This Topic
    Description

    Play HTTP Live Stream Video by URL.

    Syntax
    Visual Basic
    Public Sub PlayHLS( _
       ByVal Selector As String, _
       ByVal Source As String, _
       ByVal Options As HLSSettings _
    ) 
    Parameters
    Selector

    The CSS3 Selector of the VIDEO element to attach HLS.js. If set to "_new", a new VIDEO element will be used.

    If you are unfamiliar with CSS3 Selectors have a look in Finding the correct CSS3 Selector article.

    Source

    The HTTP Live Stream URL to play.

    Options

    The HTTP Live Stream options object.

    Remarks

    WebKitX wraps HLS.js in order to offer HTTP Live Stream. HLS.js is a JavaScript library which implements an HTTP Live Streaming client. It relies on HTML5 video and MediaSource Extensions for playback. It works by transmuxing MPEG-2 Transport Stream and AAC/MP3 streams into ISO BMFF (MP4) fragments. The PlayHLS method of WebKitX downloads HLS.js, waits for it to initialize, attaches it to a VIDEO element and starts playing.

    Example
    Option Explicit
    
    Private Sub Form_Load()
        WebKitX1.EnableHighDPISupport
    End Sub
    
    Private Sub Form_Resize()
        On Error Resume Next
        WebKitX1.Move 0, 0, ScaleWidth, ScaleHeight - Text1.Height
        Text1.Move 0, ScaleHeight - Text1.Height, ScaleWidth, Text1.Height
        Err.Clear
    End Sub
    
    Private Sub mnuDevTools_Click()
        WebKitX1.ShowDevTools 0
    End Sub
    
    Private Sub WebKitX1_OnCreate(ByVal Settings As WebKitXCEF3Lib.ISettings, CommandLineSwitches As String)
        
        Settings.plugins = False
        Settings.cache_path = App.Path + "\MyCache"
        Settings.application_cache = App.Path + "\MyAppCache"
        Settings.persist_session_cookies = 1
        Settings.persist_user_preferences = 1
        Settings.enable_high_dpi_support = True
        Settings.user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36"
        
        CommandLineSwitches = "--autoplay-policy=no-user-gesture-required"
            
    End Sub
    
    Private Sub WebKitX1_OnBrowserReady()
    
        Dim Options As New HLSSettings
        
        Options.debug = True
        Options.Controls = True
        
        WebKitX1.PlayHLS "_new", "https://test-streams.mux.dev/x36xhzz/x36xhzz.m3u8", Options
        
    End Sub
    
    Private Sub mnuPlay_Click()
        WebKitX1.PlayHLS "_new", "", Nothing
    End Sub
    
    Private Sub mnuPause_Click()
        WebKitX1.PauseHLS "_new"
    End Sub
    
    Private Sub WebKitX1_OnConsoleMessage(ByVal ConsoleMessage As String, ByVal Source As String, ByVal Line As Long)
        Text1.Text = Text1.Text + ConsoleMessage + vbCrLf
        Text1.SelStart = Len(Text1.Text)
    End Sub
    See Also