• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

abema / go-simple-m3u8 / 12159355570

04 Dec 2024 12:05PM UTC coverage: 65.434% (-13.7%) from 79.183%
12159355570

push

sunfish-shogi
Update example

0 of 6 new or added lines in 1 file covered. (0.0%)

102 existing lines in 1 file now uncovered.

407 of 622 relevant lines covered (65.43%)

15.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/examples/decode/decode.go
1
package main
2

3
import (
4
        "fmt"
5
        "strings"
6

7
        m3u8 "github.com/abema/go-simple-m3u8"
8
)
9

10
const sampleData = `#EXTM3U
11
#EXT-X-STREAM-INF:BANDWIDTH=1280000,AVERAGE-BANDWIDTH=1000000
12
http://example.com/low.m3u8
13
#EXT-X-STREAM-INF:BANDWIDTH=2560000,AVERAGE-BANDWIDTH=2000000
14
http://example.com/mid.m3u8
15
#EXT-X-STREAM-INF:BANDWIDTH=7680000,AVERAGE-BANDWIDTH=6000000
16
http://example.com/hi.m3u8
17
#EXT-X-STREAM-INF:BANDWIDTH=65000,CODECS="mp4a.40.5",UNKNOWN-ATTR="non-standard"
18
http://example.com/audio-only.m3u8
19
`
20

21
func main() {
×
22
        playlist, err := m3u8.DecodePlaylist(strings.NewReader(sampleData))
×
23
        if err != nil {
×
24
                panic(err)
×
25
        }
26
        fmt.Println("Type:", playlist.Type())
×
27
        fmt.Println("Tags:", len(playlist.Master().Tags))
×
28
        for name, values := range playlist.Master().Tags {
×
29
                fmt.Printf("  %s: %d\n", name, len(values))
×
30
        }
×
31
        fmt.Println("Streams:")
×
32
        for i, stream := range playlist.Master().Streams {
×
33
                fmt.Printf("  %d:\n", i)
×
34
                height, width, _ := stream.Attributes.Resolution()
×
NEW
35
                bandwidth, _ := stream.Attributes.Bandwidth()
×
NEW
36
                averageBandwidth, _ := stream.Attributes.AverageBandwidth()
×
37
                fmt.Println("    Height:", height)
×
38
                fmt.Println("    Width:", width)
×
NEW
39
                fmt.Println("    Bandwidth:", bandwidth)
×
NEW
40
                fmt.Println("    AverageBandwidth:", averageBandwidth)
×
NEW
41
                fmt.Println("    Codecs:", stream.Attributes.Codecs())
×
NEW
42
                fmt.Println("    UnknownAttr:", stream.Attributes["UNKNOWN-ATTR"])
×
43
                fmt.Println("    URI:", stream.URI)
×
44
        }
×
45
}
46

47
/* Output:
48
Type: master
49
Tags: 1
50
  EXTM3U: 1
51
Streams:
52
  0:
53
    Height: 0
54
    Width: 0
55
    Bandwidth: 1280000
56
    AverageBandwidth: 1000000
57
    Codecs: []
58
    UnknownAttr:
59
    URI: http://example.com/low.m3u8
60
  1:
61
    Height: 0
62
    Width: 0
63
    Bandwidth: 2560000
64
    AverageBandwidth: 2000000
65
    Codecs: []
66
    UnknownAttr:
67
    URI: http://example.com/mid.m3u8
68
  2:
69
    Height: 0
70
    Width: 0
71
    Bandwidth: 7680000
72
    AverageBandwidth: 6000000
73
    Codecs: []
74
    UnknownAttr:
75
    URI: http://example.com/hi.m3u8
76
  3:
77
    Height: 0
78
    Width: 0
79
    Bandwidth: 65000
80
    AverageBandwidth: 0
81
    Codecs: [mp4a.40.5]
82
    UnknownAttr: "non-standard"
83
    URI: http://example.com/audio-only.m3u8
84
*/
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc