# تعديل مشغل الفيديو بخطوات بسيطة

**URL:** <https://meta.discourse.org/t/video/279149>\
**Category:** Development\
**Tags:** chinese-translation\
**Created:** [15 سبتمبر 2023، 1:11م UTC](https://meta.discourse.org/t/video/279149 "2023-09-15T13:11:03Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Lhc\_fl](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lhc_fl/32/268115_2.png) [@Lhc\_fl](https://meta.discourse.org/u/Lhc_fl)\
**Post date:** [17 سبتمبر 2023، 8:05ص UTC](https://meta.discourse.org/t/video/279149/4 "2023-09-17T08:05:39Z")

</div>

> [@zengyunsi](#):
>
> ```plaintext
> setInterval(() => {
> let newUrl = location.href;
> if (curUrl !== newUrl) {
> curUrl = newUrl
> if (document.querySelector("video")) {
> new Plyr('video')
> }
> }
> }, 10)
> 
> ```

???

بصراحة، هذه شفرة سيئة للغاية، فظيعة.  
ستقوم بتشغيل دالة كل 10 مللي ثانية لن تعمل في 99٪ من الوقت، وهو إهدار كبير للأداء.  
بالتأكيد، يمكن لجهاز كمبيوتر منزلي تحمل هذه التكلفة … لكنها غير أنيقة للغاية.

IMHO this is very bad code, awful.  
It will run a function every 10 milliseconds that will not work 99% of the time, which is a huge waste of performance.  
Sure, a home computer could support the expense… but it’s just so inelegant

يجب عليك استخدام واجهة برمجة تطبيقات discourse للقيام بذلك. استخدم هذا:  
You should use discourse’s API to do this. use this:

```plaintext
<script type="text/discourse-plugin" version="0.8">
api.onPageChange(() => {
        if (document.querySelector("video")) {
            new Plyr('video');
        }
});
</script>

```

> [@zengyunsi](#):
>
> Below is what I paid $50 for someone to help me modify

~~You should have just found mine (just kidding)~~

---

_[View the full topic](https://meta.discourse.org/t/video/279149)._
