Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeshift #3541

Open
Najar1991 opened this issue Feb 21, 2025 · 3 comments
Open

Timeshift #3541

Najar1991 opened this issue Feb 21, 2025 · 3 comments

Comments

@Najar1991
Copy link

Is your feature request related to a problem? Please describe.

Modifying the timeshift code to prevent departures when broadcasting
Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered

في بداية الملف، أضف هذه الاستيرادات إذا لم تكن موجودة

from enigma import eServiceReference, iServiceInformation, eTimer
import time

class Timeshift:
def init(self, session):
self.session = session
self.service = None
self.record_service = None
self.timeshift_enabled = False
self.prevent_jump_on_dropout = False # خيار جديد لمنع الترحيل عند انقطاع البث
self.last_position = 0 # لتخزين الموقع الأخير عند انقطاع البث
self.check_timer = eTimer()
self.check_timer.callback.append(self.checkServiceStatus)

def activate(self):
    service = self.session.nav.getCurrentService()
    if service:
        self.service = service
        self.session.nav.recordService(self.session.nav.getCurrentlyPlayingServiceReference(), True)
        self.timeshift_enabled = True
        self.check_timer.start(100, True)  # فحص الحالة كل 100 مللي ثانية

def deactivate(self):
    if self.timeshift_enabled:
        self.session.nav.recordService(self.session.nav.getCurrentlyPlayingServiceReference(), False)
        self.timeshift_enabled = False
        self.check_timer.stop()
        self.service = None
        self.last_position = 0

def setPreventJumpOnDropout(self, enable=True):
    """تفعيل/تعطيل منع الترحيل عند انقطاع البث"""
    self.prevent_jump_on_dropout = enable
    if not enable:
        self.last_position = 0  # إعادة تعيين الموقع إذا تم تعطيل الميزة

def checkServiceStatus(self):
    if self.timeshift_enabled and self.service:
        info = self.service.info()
        if info:
            is_playing = info.getInfo(iServiceInformation.sIsVideo) != -1 or info.getInfo(iServiceInformation.sIsAudio) != -1
            buffer_fill = info.getInfo(iServiceInformation.sBuffer)  # تحقق من ملء الذاكرة المؤقتة

            if is_playing and buffer_fill > 0:
                seek = self.service.seek()
                if seek:
                    self.last_position = seek.getPlayPosition()  # تحديث الموقع الأخير
            elif self.prevent_jump_on_dropout and self.last_position > 0:
                # في حالة انقطاع البث، عُد إلى الموقع الأخير بدلاً من القفز
                seek = self.service.seek()
                if seek:
                    seek.seekTo(self.last_position)
                    print("[Timeshift] انقطاع البث، يتم الاحتفاظ بالموقع الأخير:", self.last_position)
            else:
                print("[Timeshift] انقطاع البث، القفز أو التوقف ممكن بناءً على الإعدادات.")

    if self.timeshift_enabled:
        self.check_timer.start(100, True)  # استمر في الفحص

Additional context
Add any other context or screenshots about the feature request here.
Sorry for arabic comments

@jbleyel
Copy link
Contributor

jbleyel commented Feb 21, 2025

Please use only English comments.
You can also create a pull request.

@jbleyel
Copy link
Contributor

jbleyel commented Feb 22, 2025

Please provide the complete py file because this is only a part of whatever.
There is no "class Timeshift:" in ATV.
I'm also not able to find "setPreventJumpOnDropout".
Do you really have tested this based on the latest ATV code?

@jbleyel
Copy link
Contributor

jbleyel commented Mar 1, 2025

Any updates?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants