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
media [options]
Options
|
Option |
Short |
Required |
Default |
Description |
|---|---|---|---|---|
|
|
|
No |
|
Media channel to configure |
|
|
|
No |
false |
Upload file specified in --path |
|
|
|
No |
false |
Download file specified in --name |
|
|
|
No |
false |
Remove file specified in --name |
|
|
|
No |
false |
Activate file specified in --name on --channel |
|
|
|
No |
|
Local file path for upload or download destination |
|
|
|
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
media
Output:
Available Media files:
audio_test_1khz.wav
video_intro.mp4
logo.png
background.jpg
alert_sound.wav
Upload Media File
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
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
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
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
-
Lists current media files
-
Validates local file exists
-
Uploads file to device storage
-
File is stored but NOT activated
-
Reports success
-
File available for future activation
Activate Operation
-
Lists current media files
-
Validates channel exists
-
Validates channel is a media channel (Audio/Video/Image)
-
Sets channel value to filename via
Hardware.SetValue() -
Waits up to 10 seconds for confirmation
-
Reports success
Download Operation
-
Lists current media files
-
Validates name is specified
-
Validates path is specified
-
Downloads file from device via
Hardware.DownloadMediaFile() -
Saves to local path
-
Reports success
Remove Operation
-
Lists current media files
-
Validates name is specified
-
Deletes file from device via
Hardware.DeleteMediaFile() -
Reports success
-
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:
list --filter ".*AUDIO.*|.*VIDEO.*|.*IMAGE.*"
Use Cases
Audio Playback
# 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
# Upload logo
media --upload --path "company_logo.png"
# Display on screen
media --activate --name "company_logo.png" --channel "LCD_IMAGE"
Video Testing
# 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
# 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
# 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
# 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:
# 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)
media --upload --path "missing.wav"
File missing.wav does not exist
Solution: Verify local file path
Channel Not Found
media --activate --name "audio.wav" --channel "NONEXISTENT"
Channel NONEXISTENT not found
Solution: Use list command to find correct channel name
Not a Media Channel
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
media --activate --name "audio.wav"
Channel must be defined for activate
Solution: Provide required --channel parameter
Mutually Exclusive Operations
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
-
List First: Always list media files to see what's available
-
Unique Names: Use unique, descriptive filenames
-
Test Before Activation: Upload and verify before activating
-
Clean Up: Remove unused files to free storage
-
Verify Format: Ensure media format is supported by hardware
-
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
# 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
# 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
# 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:
# 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"