Android Question How can i playback .m3u8 files-links?

stp

Active Member
Licensed User
Longtime User
Does any one know how to playback .m3u8 files ? Is it possible using SimpleMediaManager.b4xlib ?
 

stevel05

Expert
Licensed User
Longtime User
According to this:

"An .m3u8 file is a UTF-8 encoded playlist file used to organize and sequence multimedia files for playback, commonly in streaming applications. It contains plain text that specifies the locations of media files, which can be accessed by media players for streaming audio or video content."

It is just a text file with locations, you should be able to open it, parse the data and use whichever player is appropriate for the URL's it contains.

I have never tried it so don't know if there are any problems lurking in that approach.
 
Upvote 0

stp

Active Member
Licensed User
Longtime User
I
According to this:

"An .m3u8 file is a UTF-8 encoded playlist file used to organize and sequence multimedia files for playback, commonly in streaming applications. It contains plain text that specifies the locations of media files, which can be accessed by media players for streaming audio or video content."

It is just a text file with locations, you should be able to open it, parse the data and use whichever player is appropriate for the URL's it contains.

I have never tried it so don't know if there are any problems lurking in that approach.
Try to find a way to play-stream. Maybe using exoplayer but have no experience.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Just prepare the hls source for exolayer, it will play m3u8.
In the example of Exoplayer library. search keyword CreateHLSSource, it will tell you how to use..

B4X:
Player.Prepare(Player.CreateHLSSource("https://bitdash-a.akamaihd.net/content/sintel/hls/playlist.m3u8"))
 
Upvote 0

stp

Active Member
Licensed User
Longtime User
Thank you. I folowed Erel's https://www.b4x.com/android/forum/threads/b4a-v13-0-beta-is-available-for-download.162136/
and now dont get any errors!!!

pppz.jpg

code:
Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI
    Private SimpleExoPlayerView1 As SimpleExoPlayerView
    Private Player As SimpleExoPlayer
End Sub

Public Sub Initialize
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    '----- comment out that 2 lines   and add comment to m3u8 block to play the mp4
    'Player.Initialize("player")
    SimpleExoPlayerView1.Player = Player
    'Player.Prepare(Player.CreateUriSource("https://bestvpn.org/html5demos/assets/dizzy.mp4"))
    
    'That is for m3u8---------------------
    Player.Initialize("player")
    Dim sources As List
    sources.Initialize
    sources.Add(Player.CreateHLSSource("https://r1-ndr.ykt.cbern.com.cn/edu_product/65/video/17b2ed7f547a11eb96b8fa20200c3759/fc490e8bb61d62ff98f81160030c1d43.1280.720.false/fc490e8bb61d62ff98f81160030c1d43.1280.720.m3u8"))
    Player.Prepare(Player.CreateListSource(sources))
    SimpleExoPlayerView1.Player = Player
    Player.Play
        
End Sub
 
Upvote 0
Top