Closed kaihendry closed 7 years ago
The error you should be getting is:
./main.go:29: cannot use myVariantParams literal (type myVariantParams) as type m3u8.VariantParams in argument to masterPlaylist.Append
This is because the append method on MasterPlaylist is
func (p *MasterPlaylist) Append(uri string, chunklist *MediaPlaylist, params VariantParams)
As Go is a strongly typed language, the only type that can be used for the 3rd argument is a type github.com/grafov/m3u8.VariantParams
.
So you won't be able to do exactly what you want this way.
If the HLS RFC does have this as a field, we can add it to the VariantParams
type, but if you're trying to add a custom field to be added when calling the String()
method, then you'll need to do a lot more work with how the API is right now (we don't support custom fields).
Side note, because the Append method already resets the cache, you don't need to do that.
masterPlaylist.ResetCache()
Removing the above line shouldn't change the output.
I ended up adding what I needed by forking the repo here: https://github.com/Spuul/go-m3u8/commit/a418099cf75c3a917a309d5cd1d3641c6fdeee84
Yeah that would be the change that's required to add support for that field (to write that field, but you'll need to do more to read the field), I take it this isn't a field in the HLS RFC? If it is, we'll be happy to add that field ourselves.
It's a custom field. We're also using a Javascript library https://github.com/tedconf/node-m3u8 which has a non-annoying item.set API. I am not sure how that works in a strongly typed sense..
If it's a custom field and you're OK with running a fork, then that'll be the best option until we support some kind of custom fields, such as VariantParams
taking on a X map[string]string
type.
There was another request for custom fields: #82. I think we need some time for clarifying needs for this and implementing it without breaking existent API. So thank for a question!
Another field I need is AVERAGE-BANDWIDTH.. guess I will be adding it to my fork. https://github.com/Spuul/go-m3u8
Any field in the the HLS draft RFC can be added to this library by either asking if we can implement or sending a pull request. It's only custom fields that there's a limitation and a fork may be your best option.
Ok, I'll try implement it and do a pull request spefically only upon AVERAGE-BANDWIDTH
Sorry, I am a Golang newbie and my use case is to introduce a new key into the variant called 'rendition-id' to help clients create a rendition switcher.
Perhaps this is the same as #82. Anyway, just thought I'd convey my use case. My tact now is to fork and add the missing values.