Skip to content

Commit

Permalink
added skip function
Browse files Browse the repository at this point in the history
  • Loading branch information
Itz-Agasta committed Feb 5, 2025
1 parent d9f152f commit 2ab97a8
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 62 deletions.
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ MUSIC_FOLDER=/path/to/your/music

#Spotify client id and secret for searching tracks
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
REDIRECT_URI=http://localhost:3000
100 changes: 39 additions & 61 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Byte-compiled / optimized / DLL files
# Python
__pycache__/
*.py[cod]
*$py.class

*.so
.Python
.coverage
.coverage.*
.pytest_cache/
.mypy_cache/
.dmypy.json
dmypy.json
.tox/
.nox/

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
Expand All @@ -24,78 +32,48 @@ share/python-wheels/
*.egg
MANIFEST

# PyInstaller
*.manifest
*.spec
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Installer logs
# IDE settings
.vscode/
.idea/
*.swp
*.swo
*.swn
*.bak

# Project specific
.cache/
run_ui.sh
userfiles/recents.txt
.ethos/

# Logs and databases
*.log
*.sqlite
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
# Test reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
pytest-cache-files-hgpg68ht/*
cover/

# Translations
*.mo
*.pot

# Sphinx documentation
# Documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# dotenv
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/


# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Editor directories
.vscode/
.idea/


#extra
.cache
.DS_Store

#shell-script
./run_ui.sh
44 changes: 44 additions & 0 deletions ethos/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,50 @@ def get_volume(self) -> int:

def get_state(self) -> any:
return self.player.get_state()

def skip_forward(self, seconds: int = 5):
"""
Skip forward by a specified number of seconds.
Args:
- seconds (int): Number of seconds to skip forward. Default is 5.
"""
if not self.current_track:
return

current_time = self.player.get_time()
if current_time == -1: # No media or error
return

new_time = current_time + seconds * 1000

# Ensure ethos don't skip beyond the end of the track
media = self.player.get_media()
if media:
duration = media.get_duration()
if duration != -1:
new_time = min(new_time, duration)

self.player.set_time(new_time)

def skip_backward(self, seconds: int = 5):
"""
Skip backward by a specified number of seconds.
Args:
- seconds (int): Number of seconds to skip backward. Default is 5.
"""
if not self.current_track:
return

current_time = self.player.get_time()
if current_time == -1: # No media or error
return

new_time = current_time - seconds * 1000
new_time = max(new_time, 0) # Ensure time doesn't go negative

self.player.set_time(new_time)


class TrackInfo:
Expand Down

0 comments on commit 2ab97a8

Please sign in to comment.