E-Sharp Helpcenter
Breadcrumbs

Media command

Media File Management

Description

The media command manages media files (audio, video, and image files) on the Accordion device. It supports uploading files from your local system, downloading files to your local system, activating files on specific media channels, and removing files from the device.

Syntax

Bash
media [options]

Options

Option

Short

Required

Default

Description

--channel

-c

No


Media channel to configure

--upload

-u

No

false

Upload file specified in --path

--download

-d

No

false

Download file specified in --name

--remove

-r

No

false

Remove file specified in --name

--activate

-a

No

false

Activate file specified in --name on --channel

--path

-p

No


Local file path for upload or download destination

--name

-n

No


Media file name on device

Options Details

  • --channel: Name of audio, video, or image channel (required for activate operation)

  • --upload: Uploads local file to device storage

  • --download: Downloads device file to local storage

  • --remove: Deletes file from device storage

  • --activate: Sets specified file as active on the channel

  • --path: Local filesystem path (required for upload/download)

  • --name: Filename on device (required for activate/remove/download)

Mutually Exclusive Options

  • Upload and Download: Cannot be used together

  • Remove and Activate: Cannot be used together

Examples

List Available Media Files

Bash
media

Output:

Available Media files:
audio_test_1khz.wav
video_intro.mp4
logo.png
background.jpg
alert_sound.wav

Upload Media File

Bash
media --upload --path "C:\media\new_audio.wav"

Output:

Available Media files:
existing_file.wav
Uploaded C:\media\new_audio.wav

Activate Media on Channel

Bash
media --activate --name "audio_test_1khz.wav" --channel "AUDIO_OUT_1"

Output:

Available Media files:
audio_test_1khz.wav
video_intro.mp4
Activated audio_test_1khz.wav on channel AUDIO_OUT_1

Download Media File

Bash
media --download --name "captured_audio.wav" --path "C:\downloads\audio.wav"

Output:

Available Media files:
captured_audio.wav
Downloaded captured_audio.wav to C:\downloads\audio.wav

Remove Media File

Bash
media --remove --name "old_file.wav"

Output:

Available Media files:
old_file.wav
other_file.mp4
Removed old_file.wav

Available Media files:
other_file.mp4

Shows updated list after removal.

Output Format

Available Media files:
filename1.wav
filename2.mp4
filename3.png
[Operation result messages]

Output Colors

  • Dark Gray: Media filenames (padded to 60 characters)

  • Green: Success messages

  • Red: Error messages

Behavior

Upload Operation

  1. Lists current media files

  2. Validates local file exists

  3. Uploads file to device storage

  4. File is stored but NOT activated

  5. Reports success

  6. File available for future activation

Activate Operation

  1. Lists current media files

  2. Validates channel exists

  3. Validates channel is a media channel (Audio/Video/Image)

  4. Sets channel value to filename via Hardware.SetValue()

  5. Waits up to 10 seconds for confirmation

  6. Reports success

Download Operation

  1. Lists current media files

  2. Validates name is specified

  3. Validates path is specified

  4. Downloads file from device via Hardware.DownloadMediaFile()

  5. Saves to local path

  6. Reports success

Remove Operation

  1. Lists current media files

  2. Validates name is specified

  3. Deletes file from device via Hardware.DeleteMediaFile()

  4. Reports success

  5. Lists updated media files

Supported Media Types

The device supports:

  • Audio Files: .wav, .mp3, .flac, etc.

  • Video Files: .mp4, .avi, .mkv, etc.

  • Image Files: .png, .jpg, .bmp, .gif, etc.

Specific format support depends on hardware capabilities.

Channel Types

Media can be activated on channels implementing:

  • IAudioChannel: Audio playback/capture channels

  • IVideoChannel: Video playback/display channels

  • IImageChannel: Image display channels

Use list command to see available media channels:

Bash
list --filter ".*AUDIO.*|.*VIDEO.*|.*IMAGE.*"

Use Cases

Audio Playback

Bash
# Upload audio file
media --upload --path "alert.wav"

# Activate on audio channel
media --activate --name "alert.wav" --channel "SPEAKER_OUT"

# Wait for playback (if applicable)
wait --channel "PLAYBACK_DONE" --value "1" --timeout 5000

Image Display

Bash
# Upload logo
media --upload --path "company_logo.png"

# Display on screen
media --activate --name "company_logo.png" --channel "LCD_IMAGE"

Video Testing

Bash
# Upload test video
media --upload --path "test_pattern.mp4"

# Play on video output
media --activate --name "test_pattern.mp4" --channel "HDMI_VIDEO_OUT"

Capture and Download

Bash
# Capture audio (via other commands)
set --channel "AUDIO_CAPTURE" --value "START"
wait --channel "CAPTURE_COMPLETE" --value "1" --timeout 30000

# Download captured file
media --download --name "captured_audio.wav" --path "C:\recordings\test1.wav"

Replace Media File

Bash
# Remove old version
media --remove --name "old_audio.wav"

# Upload new version
media --upload --path "new_audio.wav"

# Activate updated file
media --activate --name "new_audio.wav" --channel "AUDIO_OUT"

Batch Upload

Bash
# Upload multiple files
media --upload --path "alert1.wav"
media --upload --path "alert2.wav"
media --upload --path "alert3.wav"

# List all
media

File Management

Storage Location

Media files are stored in device storage:

  • Persists across reboots

  • Limited by device storage capacity

  • Check available space before large uploads

File Naming

  • Use descriptive names

  • Avoid special characters

  • Include file extensions

  • Case-sensitive on most devices

Cleanup

Regularly remove unused files:

Bash
# List files
media

# Remove unused files
media --remove --name "old_test1.wav"
media --remove --name "old_test2.mp4"

# Verify cleanup
media

Error Handling

File Not Found (Upload)

Bash
media --upload --path "missing.wav"
File missing.wav does not exist

Solution: Verify local file path

Channel Not Found

Bash
media --activate --name "audio.wav" --channel "NONEXISTENT"
Channel NONEXISTENT not found

Solution: Use list command to find correct channel name

Not a Media Channel

Bash
media --activate --name "audio.wav" --channel "GPIO_PIN"
Channel GPIO_PIN is not a media channel

Solution: Ensure channel is Audio/Video/Image type

Missing Parameters

Bash
media --activate --name "audio.wav"
Channel must be defined for activate

Solution: Provide required --channel parameter

Mutually Exclusive Operations

Bash
media --upload --download --path "file.wav"
Upload and Download are mutually exclusive

Solution: Use only one operation per command

Activation Timeout

If activation fails within 10-second timeout:

  • Check channel supports the file format

  • Verify file is not corrupted

  • Check device logs for errors

Best Practices

  1. List First: Always list media files to see what's available

  2. Unique Names: Use unique, descriptive filenames

  3. Test Before Activation: Upload and verify before activating

  4. Clean Up: Remove unused files to free storage

  5. Verify Format: Ensure media format is supported by hardware

  6. Backup Important Files: Download critical media files for backup

Performance Considerations

Upload Times

Depend on:

  • File size

  • Network connection speed

  • Device storage speed

Typical rates:

  • Small files (< 1 MB): < 1 second

  • Medium files (1-10 MB): 1-10 seconds

  • Large files (> 10 MB): 10+ seconds

Activation Times

  • Usually instant (< 100ms)

  • Wait timeout: 10 seconds

  • Playback/display start time varies by hardware

Advanced Workflows

Automated Testing

Bash
# Upload test media
media --upload --path "test_1khz.wav"
media --upload --path "test_440hz.wav"

# Test each frequency
for file in test_1khz.wav test_440hz.wav; do
    media --activate --name $file --channel "AUDIO_OUT"
    wait --channel "PLAYBACK_DONE" --value "1" --timeout 5000
    # Measure and verify output
done

# Cleanup
media --remove --name "test_1khz.wav"
media --remove --name "test_440hz.wav"

Media Library Management

Bash
# Download all media for backup
media --download --name "file1.wav" --path "backup\file1.wav"
media --download --name "file2.mp4" --path "backup\file2.mp4"
media --download --name "file3.png" --path "backup\file3.png"

# Clear device storage
media --remove --name "file1.wav"
media --remove --name "file2.mp4"
media --remove --name "file3.png"

# Upload new library
media --upload --path "new_lib\audio1.wav"
media --upload --path "new_lib\video1.mp4"

Format Testing

Bash
# Test different audio formats
for format in test.wav test.mp3 test.flac; do
    media --upload --path $format
    media --activate --name $format --channel "AUDIO_OUT"
    # Verify playback
    # Log results
done

Storage Management

Monitor device storage:

Bash
# List all media files
media

# Remove unused files to free space
media --remove --name "unused1.wav"
media --remove --name "unused2.mp4"

# Upload new files
media --upload --path "new_file.wav"