forked from grafov/m3u8
-
Notifications
You must be signed in to change notification settings - Fork 2
/
doc.go
65 lines (50 loc) · 2.12 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Package m3u8 is parser & generator library for Apple HLS.
/* This is a most complete opensource library for parsing and
generating of M3U8 playlists used in HTTP Live Streaming (Apple
HLS) for internet video translations.
M3U8 is simple text format and parsing library for it must be simple
too. It did not offer ways to play HLS or handle playlists over
HTTP. Library features are:
* Support HLS specs up to version 5 of the protocol.
* Parsing and generation of master-playlists and media-playlists.
* Autodetect input streams as master or media playlists.
* Offer structures for keeping playlists metadata.
* Encryption keys support for usage with DRM systems like Verimatrix (http://verimatrix.com) etc.
* Support for non standard Google Widevine (http://www.widevine.com) tags.
Library coded accordingly with IETF draft
http://tools.ietf.org/html/draft-pantos-http-live-streaming
Examples of usage may be found in *_test.go files of a package. Also
see below some simple examples.
Create simple media playlist with sliding window of 3 segments and
maximum of 50 segments.
p, e := NewMediaPlaylist(3, 50)
if e != nil {
panic(fmt.Sprintf("Create media playlist failed: %s", e))
}
for i := 0; i < 5; i++ {
e = p.Add(fmt.Sprintf("test%d.ts", i), 5.0)
if e != nil {
panic(fmt.Sprintf("Add segment #%d to a media playlist failed: %s", i, e))
}
}
fmt.Println(p.Encode(true).String())
We add 5 testX.ts segments to playlist then encode it to M3U8 format
and convert to string.
Next example shows parsing of master playlist:
f, err := os.Open("sample-playlists/master.m3u8")
if err != nil {
fmt.Println(err)
}
p := NewMasterPlaylist()
err = p.DecodeFrom(bufio.NewReader(f), false)
if err != nil {
fmt.Println(err)
}
fmt.Printf("Playlist object: %+v\n", p)
We are open playlist from the file and parse it as master playlist.
*/
package m3u8
// Copyright 2013-2019 The Project Developers.
// See the AUTHORS and LICENSE files at the top-level directory of this distribution
// and at https://github.com/grafov/m3u8/
// ॐ तारे तुत्तारे तुरे स्व