Documentation
¶
Index ¶
- Variables
- func RenderText(text string, opts TextOptions) image.Image
- type ImageServer
- type Option
- type Renderer
- func (r *Renderer) Close() error
- func (r *Renderer) Display(ctx context.Context, tv *TV, img image.Image) error
- func (r *Renderer) DisplayHLS(ctx context.Context, tv *TV, hlsURL string, title string) error
- func (r *Renderer) DisplayImage(ctx context.Context, tv *TV, img image.Image) error
- func (r *Renderer) DisplayImageJPEG(ctx context.Context, tv *TV, jpegData []byte) error
- func (r *Renderer) DisplayJPEG(ctx context.Context, tv *TV, jpegData []byte) error
- func (r *Renderer) DisplayText(ctx context.Context, tv *TV, text string) error
- func (r *Renderer) DisplayTextWithOptions(ctx context.Context, tv *TV, text string, opts TextOptions) error
- func (r *Renderer) DisplayVideo(ctx context.Context, tv *TV, videoURL string, title string) error
- func (r *Renderer) ServerURL() string
- func (r *Renderer) Stop(ctx context.Context, tv *TV) error
- func (r *Renderer) StreamVideo(ctx context.Context, tv *TV, videoURL string, title string) error
- type TV
- type TextOptions
Constants ¶
This section is empty.
Variables ¶
var ( Black = color.RGBA{0, 0, 0, 255} White = color.RGBA{255, 255, 255, 255} )
Predefined colors
Functions ¶
func RenderText ¶
func RenderText(text string, opts TextOptions) image.Image
RenderText renders text to an image using a simple bitmap font Note: This uses a basic pixel font. For better fonts, render your own image.
Types ¶
type ImageServer ¶
type ImageServer struct {
// contains filtered or unexported fields
}
ImageServer serves images over HTTP for TVs to fetch
func NewImageServer ¶
func NewImageServer() (*ImageServer, error)
NewImageServer creates a new image server on an available port
func (*ImageServer) Store ¶
func (s *ImageServer) Store(jpegData []byte) string
Store stores an image and returns its URL
func (*ImageServer) StreamURL ¶
func (s *ImageServer) StreamURL() string
StreamURL returns the URL for the streaming endpoint
func (*ImageServer) URL ¶
func (s *ImageServer) URL() string
URL returns the base URL of the image server
func (*ImageServer) UpdateLatestFrame ¶
func (s *ImageServer) UpdateLatestFrame(jpegData []byte)
UpdateLatestFrame updates the latest frame for streaming mode
type Option ¶
type Option func(*Renderer)
Option configures a Renderer
func WithTextOptions ¶
func WithTextOptions(opts TextOptions) Option
WithTextOptions sets the default text rendering options
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is the high-level API for displaying content on Smart TVs.
Two display modes are supported:
1. Static Image Mode (for most DLNA TVs like JVC, Samsung, LG):
- Use DisplayImage() or DisplayImageJPEG() to show a static image
- Each call triggers a full content switch (brief transition visible)
- Designed for dashboards, info displays, infrequent updates
- Image stays displayed until explicitly changed
2. Video Streaming Mode (requires TV video streaming support):
- Use StreamVideo() to play HLS/video streams
- TV handles continuous playback internally
- Not supported by all TVs via DLNA
func NewRenderer ¶
NewRenderer creates a new Renderer with an embedded image server
func (*Renderer) DisplayHLS ¶
DisplayHLS is deprecated. Use StreamVideo instead.
func (*Renderer) DisplayImage ¶
DisplayImage shows a static image on the TV. The image remains displayed until another DisplayImage call or Stop. Each call triggers a content switch which may cause a brief transition.
Note: Go's standard JPEG encoder may not be compatible with all TVs. If you encounter "file not supported" errors, use DisplayImageJPEG with JPEG data generated by ffmpeg+imagemagick for proper JFIF headers.
func (*Renderer) DisplayImageJPEG ¶
DisplayImageJPEG shows a static JPEG image on the TV. Use this when you have pre-encoded JPEG data (e.g., from ffmpeg). The image remains displayed until another call or Stop.
For JVC and similar TVs that require JFIF-compliant JPEGs, generate the JPEG using: ffmpeg -> imagemagick (magick convert)
func (*Renderer) DisplayJPEG ¶
DisplayJPEG is deprecated. Use DisplayImageJPEG instead.
func (*Renderer) DisplayText ¶
DisplayText renders text as an image and displays it on the TV
func (*Renderer) DisplayTextWithOptions ¶
func (r *Renderer) DisplayTextWithOptions(ctx context.Context, tv *TV, text string, opts TextOptions) error
DisplayTextWithOptions renders text with custom options and displays it
func (*Renderer) DisplayVideo ¶
DisplayVideo is deprecated. Use StreamVideo instead.
func (*Renderer) StreamVideo ¶
StreamVideo sends a video stream URL to the TV for continuous playback. Supports HLS (.m3u8), MPEG-TS, and other video formats depending on TV.
Note: Many consumer TVs (including JVC VIDAA) do not support video streaming via DLNA AVTransport. Use Static Image Mode for these TVs.
type TV ¶
type TV struct {
Name string // Friendly name (e.g., "TV Salon")
IP string // IP address
Port int // UPnP port
ControlURL string // Full AVTransport control endpoint URL
BaseURL string // Base URL for the device
}
TV represents a discovered Smart TV
type TextOptions ¶
type TextOptions struct {
FontSize int // Character height in pixels (default 100)
Width int // Image width (default 1920)
Height int // Image height (default 1080)
Color color.Color // Text color (default white)
Background color.Color // Background color (default black)
}
TextOptions configures text rendering