You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AIOZ Stream is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.
Project description
AIOZ Stream's Go client streamlines the coding process. Chunking files is handled for you, as is pagination and refreshing your tokens.
Getting started
Installation
go get github.com/AIOZNetwork/aioz-stream-go-client
Code sample
For a more advanced usage you can checkout the rest of the documentation in the docs directory
import (
"context""fmt""os"
aiozstreamsdk "github.com/AIOZNetwork/aioz-stream-go-client"
)
funcmain() {
// Connect to production environmentpublicKey:="YOUR_PUBLIC_KEY"// Replace with your public keysecretKey:="YOUR_SECRET_KEY"// Replace with your actual API secret keyapiCreds:= aiozstreamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client:=aiozstreamsdk.ClientBuilder(apiCreds).Build()
// Create a video objecttitle:="Sample Video Title"videoData:= aiozstreamsdk.CreateVideoRequest{
Title: &title,
}
createResult, err:=client.Video.Create(videoData)
iferr!=nil {
fmt.Fprintf(os.Stderr, "Error creating video: %v\n", err)
return
}
videoId:=createResult.Data.Id// Get the video ID from the response// Open the video filevideoFile, err:=os.Open("./path/to/video.mp4")
iferr!=nil {
fmt.Println("Error opening video file:", err)
return
}
defervideoFile.Close() // Close the file after usefileInfo, err:=videoFile.Stat()
iferr!=nil {
fmt.Fprintf(os.Stderr, "Error getting file info: %v\n", err)
return
}
fileSize:=fileInfo.Size()
fileName:=fileInfo.Name()
// Option 1: Use client upload with videoIderr=client.UploadVideo(context.Background(), *videoId, fileName, videoFile, fileSize)
iferr!=nil {
fmt.Fprintf(os.Stderr, "Error uploading video with client: %v\n", err)
return
}
// Option 2: Upload parts yourself// This example is commented out as you already used option 1//_, err = client.Video.UploadPart(*videoId, nil, nil, "./path/to/video.mp4", videoFile, fileInfo.Size())//if err != nil {// fmt.Fprintf(os.Stderr, "Error uploading video part: %v\n", err)// return//}////success, err := client.Video.UploadVideoComplete(*videoId)//if err != nil {// fmt.Fprintf(os.Stderr, "Error completing video upload: %v\n", err)// return//}////jsonString, err := json.MarshalIndent(success, "", " ")//if err != nil {// fmt.Fprintf(os.Stderr, "Error marshalling response: %v\n", err)// return//}//fmt.Println(string(jsonString))fmt.Println("Video uploaded successfully!")
}
secretKey:="YOUR_SECRET_KEY"// Replace with your actual secret keypublicKey:="YOUR_PUBLIC_KEY"// Replace with your public keyapiCreds:= aiozstreamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client:=aiozstreamsdk.ClientBuilder(apiCreds).Build()
analyticsApi:=client.Analytics
secretKey:="YOUR_SECRET_KEY"// Replace with your actual secret keypublicKey:="YOUR_PUBLIC_KEY"// Replace with your public keyapiCreds:= aiozstreamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client:=aiozstreamsdk.ClientBuilder(apiCreds).Build()
apiKeyApi:=client.ApiKey
secretKey:="YOUR_SECRET_KEY"// Replace with your actual secret keypublicKey:="YOUR_PUBLIC_KEY"// Replace with your public keyapiCreds:= aiozstreamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client:=aiozstreamsdk.ClientBuilder(apiCreds).Build()
liveStreamApi:=client.LiveStream
secretKey:="YOUR_SECRET_KEY"// Replace with your actual secret keypublicKey:="YOUR_PUBLIC_KEY"// Replace with your public keyapiCreds:= aiozstreamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client:=aiozstreamsdk.ClientBuilder(apiCreds).Build()
mediaApi:=client.Media
secretKey:="YOUR_SECRET_KEY"// Replace with your actual secret keypublicKey:="YOUR_PUBLIC_KEY"// Replace with your public keyapiCreds:= aiozstreamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client:=aiozstreamsdk.ClientBuilder(apiCreds).Build()
mediaChapterApi:=client.MediaChapter
secretKey:="YOUR_SECRET_KEY"// Replace with your actual secret keypublicKey:="YOUR_PUBLIC_KEY"// Replace with your public keyapiCreds:= aiozstreamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client:=aiozstreamsdk.ClientBuilder(apiCreds).Build()
playersApi:=client.Players
secretKey:="YOUR_SECRET_KEY"// Replace with your actual secret keypublicKey:="YOUR_PUBLIC_KEY"// Replace with your public keyapiCreds:= aiozstreamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client:=aiozstreamsdk.ClientBuilder(apiCreds).Build()
playlistApi:=client.Playlist
secretKey:="YOUR_SECRET_KEY"// Replace with your actual secret keypublicKey:="YOUR_PUBLIC_KEY"// Replace with your public keyapiCreds:= aiozstreamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client:=aiozstreamsdk.ClientBuilder(apiCreds).Build()
userApi:=client.User
secretKey:="YOUR_SECRET_KEY"// Replace with your actual secret keypublicKey:="YOUR_PUBLIC_KEY"// Replace with your public keyapiCreds:= aiozstreamsdk.AuthCredentials{
PublicKey: publicKey,
SecretKey: secretKey,
}
client:=aiozstreamsdk.ClientBuilder(apiCreds).Build()
webhookApi:=client.Webhook