github.com/muxinc/mux-go@v1.1.1/examples/video/ingest/ingest.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"github.com/muxinc/mux-go"
     7  )
     8  
     9  func main() {
    10  
    11  	// API Client Initialization
    12  	client := muxgo.NewAPIClient(
    13  		muxgo.NewConfiguration(
    14  			muxgo.WithBasicAuth(os.Getenv("MUX_TOKEN_ID"), os.Getenv("MUX_TOKEN_SECRET")),
    15  		))
    16  
    17  	// Create Asset
    18  	asset, err := client.AssetsApi.CreateAsset(muxgo.CreateAssetRequest{
    19  		Input: []muxgo.InputSettings{
    20  			muxgo.InputSettings{
    21  				Url: "https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4",
    22  			},
    23  		},
    24  		PlaybackPolicy: []muxgo.PlaybackPolicy{muxgo.PUBLIC},
    25  	})
    26  	
    27  	if err == nil {
    28  		fmt.Printf("Playback URL: https://stream.mux.com/%s.m3u8 \n", asset.Data.PlaybackIds[0].Id)
    29  	} else {
    30  		fmt.Printf("Oh no, there was an error: %s \n", err)
    31  	}
    32  
    33  }