Media Player API¶
Control audio and video playback.
Playback Control¶
mediaPlay()¶
Play media file.
Parameters:
- url (str): Media file path or URL
- tag (str): Player identifier
- play (bool): Auto-start playback
mediaPlayStart()¶
Start playback.
mediaPlayPause()¶
Pause playback.
mediaPlayClose()¶
Close player.
mediaPlaySeek()¶
Seek to position.
Parameters:
- msec (int): Position in milliseconds
mediaPlaySetLooping()¶
Set loop mode.
Player Info¶
mediaPlayInfo()¶
Get playback info.
Returns: Dict with duration, position, etc.
mediaIsPlaying()¶
Check if playing.
Returns: True/False
mediaPlayList()¶
List active players.
Volume Control¶
getMediaVolume()¶
Get media volume.
Returns: Volume level (0-15)
getMaxMediaVolume()¶
Get max media volume.
getRingerVolume()¶
Get ringer volume.
getMaxRingerVolume()¶
Get max ringer volume.
Video Playback¶
videoPlay()¶
Play video fullscreen.
Parameters:
- path (str): Video file path
- wait (bool): Wait for playback to complete
Usage Example¶
import androidhelper
droid = androidhelper.Android()
# Play audio
droid.mediaPlay("/sdcard/music.mp3", tag="music")
# Check status
if droid.mediaIsPlaying("music").result:
info = droid.mediaPlayInfo("music").result
print(f"Playing: {info}")
# Seek to 30 seconds
droid.mediaPlaySeek(30000, "music")
# Close
droid.mediaPlayClose("music")
# Play video
droid.videoPlay("/sdcard/movie.mp4", wait=True)