Flutter_widget_from_html: video continue playing after locking the phone or navigate to another screen

Created on 8 May 2019  ·  11Comments  ·  Source: daohoangson/flutter_widget_from_html

Hi,
If the youtube video starts playing it won't stop if I locked the phone screen or navigate to another screen inside the app...it will stop playing if I navigate to the previous screen tho.

bug

All 11 comments

I have filed a bug in the Flutter repo, let's wait and see what can be done. I have some workaround available but it's rather dangerous because it refreshes the WebView when user navigates away or locks the phone. If there is some special state in the web page, it will be lost on reload.

I have uploaded my app to the google play console and it got rejected due to this reason:
"
  | Issue: Violation of Device and Network Abuse policy 
We don’t allow apps that interfere with, disrupt, damage, or access in an unauthorized manner the user’s device, other devices or computers, servers, networks, application programming interfaces (APIs), or services, including but not limited to other apps on the device, any Google service, or an authorized carrier’s network. Your app shouldn’t access or use the service or API in a manner that violates its terms of service. For example, your app shouldn't download, monetize, or access YouTube videos in a way that violates the YouTube Terms of Service. | Issue: Violation of Device and Network Abuse policy | We don’t allow apps that interfere with, disrupt, damage, or access in an unauthorized manner the user’s device, other devices or computers, servers, networks, application programming interfaces (APIs), or services, including but not limited to other apps on the device, any Google service, or an authorized carrier’s network.

Your app shouldn’t access or use the service or API in a manner that violates its terms of service. For example, your app shouldn't download, monetize, or access YouTube videos in a way that violates the YouTube Terms of Service.
"

after searching I found out that it most likely is because of this issue as the video continue playing in the background.
If you can support me with your workaround to give it a shot I will be grateful.

update:

After disable
webViewJs: true,
webView: true,
wf: _BlockquoteWebViewWf(),

I was able to upload my app...but the videos still a very important component inside the app and I should
commit an update as soon as I can with this issue being solved.
here is a link to my app:
https://play.google.com/store/apps/details?id=com.smarty.tahrir_news
I was not going to be able to create it without your plugin, efforts and help ...Thank you so much ♥️♥️♥️

UPDATE:
I removed the comment and created another apk and uploaded it...and surprisingly they accepted it even if it has the same code which rejected in the first apk

I think there are different reviewers so their decisions are different.

Regarding the workaround, you cannot implement in the app itself so I will add it in the plugin instead behind a flag (something like webViewWorkaround: false). Then you will be able to turn it on for your app if you need it.

Regarding the workaround,

Awesome...And I think it will be useful in ios as well because even if the video is displaying in full-screen mode and you have to minimize the screen to navigate to another screen which will stop the video, the issue is still there if you locked the screen of the iPhone...
best wishes, and Please tell me of the time the update will be released on if you can. :)

v0.2.1 has just been released, you can now set unsupportedWebViewWorkaroundForIssue37 to enable the workaround, see sample code below:

          HtmlWidget(
            html,
            unsupportedWebViewWorkaroundForIssue37: true,
            webView: true,
          ),

Please let me know if it works for you.

v0.2.1 has just been released, you can now set unsupportedWebViewWorkaroundForIssue37 to enable the workaround, see sample code below:

          HtmlWidget(
            html,
            unsupportedWebViewWorkaroundForIssue37: true,
            webView: true,
          ),

Please let me know if it works for you.

it works ...but suddenly many times this error screen shows up:
Screenshot_1559083662

beside the _BlockquoteWebViewWf method starts showing me an error :

Compiler message:
lib/screens/Webview_screen.dart:568:55: Error: The parameter 'tag' of the method '_BlockquoteWebViewWf.parseElement' has type 'String', which does not match the corresponding type, 'Element', in the overridden method, 'WidgetFactory.parseElement'.

  • 'Element' is from 'package:html/dom.dart' ('file:///C:/Users/Ahamaad/flutter/flutter_windows_v1.0.0-stable/flutter/.pub-cache/hosted/pub.dartlang.org/html-0.14.0+2/lib/dom.dart').
    Change to a supertype of 'Element', or, for a covariant parameter, a subtype.
    NodeMetadata parseElement(NodeMetadata meta, String tag) {
    ^
    file:///C:/Users/Ahamaad/flutter/flutter_windows_v1.0.0-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_widget_from_html_core-0.2.1/lib/src/core_widget_factory.dart:394:16: Context: This is the overridden method ('parseElement').
    NodeMetadata parseElement(NodeMetadata meta, dom.Element element) {
    ^
    lib/screens/Webview_screen.dart:555:14: Error: A value of type 'WebView' can't be assigned to a variable of type 'Iterable'.
  • 'WebView' is from 'package:flutter_widget_from_html/src/web_view.dart' ('file:///C:/Users/Ahamaad/flutter/flutter_windows_v1.0.0-stable/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_widget_from_html-0.2.1/lib/src/web_view.dart').
  • 'Iterable' is from 'dart:core'.
  • 'Widget' is from 'package:flutter/src/widgets/framework.dart' ('file:///C:/Users/Ahamaad/flutter/flutter_windows_v1.0.0-stable/flutter/packages/flutter/lib/src/widgets/framework.dart').
    Try changing the type of the left hand side, or casting the right hand side to 'Iterable'.
    return WebView(
    ^
    lib/screens/Webview_screen.dart:574:37: Error: The argument type 'String' can't be assigned to the parameter type 'Element'.
  • 'Element' is from 'package:html/dom.dart' ('file:///C:/Users/Ahamaad/flutter/flutter_windows_v1.0.0-stable/flutter/.pub-cache/hosted/pub.dartlang.org/html-0.14.0+2/lib/dom.dart').
    Try changing the type of the parameter, or casting the argument to 'Element'.
    return super.parseElement(meta, tag);
    ^

The assertion error is probably the same as reported here https://github.com/daohoangson/flutter_widget_from_html/issues/44. Can you post the html that is causing issue?

Regarding the _BlockquoteWebViewWf, you will need to change it a bit for 0.2.1. Sorry about this problem, this plugin is young and things are still being moved around. I will update the code in https://github.com/daohoangson/flutter_widget_from_html/issues/23 for your reference.

It doesn't have any difference from other working htmls ...but this is an example from the unworking html:

"\"لقد فعلت كل ما بوسعي\" كلمات قالتها تيريزا ماي، رئيسة الوزراء البريطانية، بكل أسى في خطابها الذي ألقته، اليوم الجمعة، من أمام مقر رئاسة الوزراء في داوننج ستريت بالعاصمة لندن، وأعلنت فيه استقالتها من منصبها بشكل رسمي في السابع من شهر يونيو المقبل، بعد فشلها في إدارة ملف خروج بريطانيا من الاتحاد الأوروبي \"البريكست\"، لتنهي 3 سنوات من الهزائم المستمرة في المنصب الذي تولته في الثالث عشر من شهر يوليو عام 2016، بعد أن صوّت البريطانيون لصالح خروج بريطانيا من الاتحاد الأوروبي."
"

دموع ماي

\n

وصرحت رئيسة الوزراء في كلمتها: \"أنا فخورة بالتقدم الذي أحرزناه خلال السنوات القليلة الماضية\"، مشيرة إلى قدرة حزبها على تحقيق \"البريكست\".

\n

وقالت ماي إنها تشعر بـ\"الأسف العميق\" لأنها لم تتمكن من الوفاء بوعد خروج بريطانيا من الاتحاد الأوروبي، وتابعت أن رئيس الوزراء الجديد سيعمل \"في مصلحة البلد\".

\n

وفي نهاية خطابها قالت وهي تغالب دموعها: \"لقد كان شرف حياتي أن أتولى رئاسة الوزراء، وأن أكون ثاني امرأة في هذا المنصب\".

\n

وأضافت: \"أنا أقوم بذلك الآن بدون سوء نية، لكن بالكثير من الامتنان بفضل الفرصة التي مُنحت لي لأخدم البلاد التي أحبها\".

\n

وفي الوقت الذي يقترب فيه عدد من أعضاء حزبها المعارضين لها للحصول على منصبها، تضيف هذه الاستقالة المزيد من الفوضى إلى الساحة السياسية البريطانية، حيث تحاول البلاد إنهاء خروجها من الاتحاد الأوروبي.

\n

ماذا سيحدث بعد ذلك؟

\n

لن تغادر رئيسة الوزراء منصبها على الفور، بعد تنحيها عن منصب زعيمة حزب المحافظين في السابع من يونيو، وستبقى في منصب رئيس الوزراء حتى يمكن اختيار خليفتها.

\n

ومن المتوقع أن تبدأ الانتخابات الداخلية في حزب المحافظين، لاختيار خليفتها في 10 يونيو، والتي قد تشهد منافسة نحو 20 مرشحا حتى الآن.

\n

وفي غضون ذلك، ستستمر ماي في القيام بمهام منصبها، إذ ستستضيف الرئيس الأمريكي دونالد ترامب في أول زيارة رسمية له في الأسبوع الأول من يونيو.

\n

لماذا استقالت تيريزا ماي من منصبها؟

\n

\n

وعندما يتم الانتهاء من تلك الزيارة، تقول صحيفة \"الصن\" البريطانية، إن المعركة ستبدأ بشكل رسمي، حيث ستنطلق المنافسات داخل حزب المحافظين لاختيار رئيس جديد للحزب، وقد تستمر لعدة أسابيع.

\n

ويعد بوريس جونسون وزير الخارجية السابق، ودومينيك راب وزير شؤون البريكست السابق، وجيريمي هانت وزير الخارجية الحالي، ومايكل جوف وزير البيئة الحالي، من أبرز المرشحين لخلافتها.

\n

وسوف يدلي أعضاء حزب المحافظين بأصواتهم لصالح المرشح الذي يعترونه الأجدر بأن يكون رئيس الوزراء القادم، في الانتخابات التي من المحتمل أن تستغرق عدة جولات لتخفيض عدد المرشحين.

\n

ففي كل جولة سيتم استبعاد المرشح الحاصل على أقل الأصوات، كما سينسحب البعض الآخر بعد أن يتأكدوا من أنهم لن يحصلوا على الدعم الكافي لهزيمة بقية المرشحين.

\n

سيتم بعد ذلك طرح المرشحين النهائيين في تصويت يشارك فيه 120 ألف عضو، ومن المحتمل أن تستغرق هذه المرحلة عدة أسابيع، وسوف تتضمن عددا من المناقشات في جميع أنحاء البلاد.

\n

وفي الانتخابات الأخيرة للحزب عام 2016، وصلت ماي وأندريا ليدسوم إلى المرحلة النهائية، إلا أن الأخيرة انسحبت بعد أن أعربت عن تأييدها لماي، وهو ما أدى إلى تخطي المرحلة النهائية ولم يحصل أعضاء الحزب على فرصة إبداء رأيهم.

\n

وتقول الصحيفة البريطانية إنه بحلول يوم السابع من يونيو، ستتوجه ماي إلى قصر باكنجهام، حيث ستلتقي الملكة، وتقدم استقالتها رسميا، وتنهي فترة قيادتها للبلاد.

\n

رئيسة وزراء بريطانيا تعلن استقالتها رسميا: فشلت

\n

\n

ومن المقرر أن يذهب من سيفوز بعد ذلك بمنصب رئيس الوزراء، لمقابلة الملكة، وذلك من أجل التصديق على توليه منصبه رسميا، وستبقى ماي في منصبها حتى ذلك الحين على الأقل، والذي قد يمتد حتى نهاية يوليو.

\n

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

\n

وقالت ماي في أكثر من مناسبة إنها ستتنحى بمجرد الانتهاء من المرحلة الأولى من خروج بريطانيا من الاتحاد الأوروبي، وقد يمنحها إعلان اليوم المزيد من الوقت لمحاولة تحقيق أي تقدم، وإلا سينظر إليها على أنها غادرت دون أن تحقق أي شيء.

\n

ماذا يعني هذا بالنسبة للبريكست؟

\n

تقول هيئة الإذاعة البريطانية \"بي بي سي\" إنه حتى الآن لم تظهر أي مؤشرات على تأثير قرار ماي بالاستقالة فى خروج بريطانيا من الاتحاد الأوروبي، مشيرة إلى أن الأمر كله يعتمد على من سيخلف ماي في منصبها، ففي حالة فوز مؤيد قوي لخروج بريطانيا من الاتحاد الأوروبي، فقد يصر على مغادرة الاتحاد الأوروبي قبل الموعد النهائي الحالي المقرر له 31 أكتوبر المقبل، أو حتى المغادرة دون التوصل إلى اتفاق خروج مع الاتحاد الأوروبي.

\n

وفي المقابل، من المتوقع أن تشهد الانتخابات الداخلية في حزب المحافظين ترشح أشخاص دعموا بقاء بريطانيا في الاتحاد الأوروبي خلال استفتاء البريكست عام 2016، كما يعارض البعض خروج بريطانيا من الاتحاد الأوروبي دون اتفاق، وآخرون منفتحون على أن تكون المملكة المتحدة أكثر ارتباطا بالاتحاد الأوروبي بعد مغادرته.

\n

وتشير الإذاعة البريطانية إلى أنه بغض النظر عن مَن سيفوز، فإنه سيواجه نفس المشكلة التي واجهتها ماي، وهي أنه لا توجد هناك أغلبية في البرلمان تدعم أي خيار من الخيارات المتاحة لخروج بريطانيا من الاتحاد الأوروبي.

\n

بسبب خطة البريكست.. صراع في حزب المحافظين لخلافة ماي

\n

\n

وذلك لدرجة أن النواب حاولوا السيطرة على عملية خروج بريطانيا من الاتحاد الأوروبي من خلال عقد سلسلة من جولات التصويت غير الملزمة حول ما يجب على الحكومة فعله، ولكن تم التصويت ضد جميع الخيارات، بدءا من إلغاء خروج بريطانيا إلى السماح بالخروج دون اتفاق.

\n

وترى \"بي بي سي\" أن ما هو واضح أنه ستكون هناك فترة أخرى من عدم اليقين، الأمر الذي يزعج الكثير من زعماء الاتحاد الأوروبي، حيث اتهم رئيس المفوضية الأوروبية جان كلود يونكر، النواب البريطانيين بأنهم يهتمون بإيجاد رئيس وزراء جديد أكثر من \"التوصل إلى اتفاق في ما بينهم\".

\n

وقال لشبكة \"سي إن إن\" يوم الأربعاء الماضي: \"لقد سئمت لأن كل ما نفعله هو انتظار موعد تأجيل البريكست التالي\".

"

_BlockquoteWebViewWf

it showing me another error now on this line
NodeMetadata parseElement(NodeMetadata meta, dom.Element e)

"Undifined class dom.Element "

Sorry about this problem, this plugin is young and things are still being moved around.

Your plugin is awesome.....keep up the great work 🥇 💯

"Undifined class dom.Element "

You need the imports at the top. Specifically this one

import 'package:html/dom.dart' as dom;

The problems have been solved in the new update

Was this page helpful?
0 / 5 - 0 ratings

Related issues

theneshofficial picture theneshofficial  ·  4Comments

ahmadkhedr picture ahmadkhedr  ·  6Comments

skipness picture skipness  ·  7Comments

mamonraab picture mamonraab  ·  7Comments

ahmadkhedr picture ahmadkhedr  ·  4Comments