0

i am trying to add swarmify with flutter i tried to use webview and i will attach the source code but the video is not working and giving me this error

I/chromium( 5322): [INFO:CONSOLE(1)] "Swarmify - swarmdetect.js: Script Append Succeeded", source: https://assets.swarmcdn.com/cross/swarmdetect.js (1) I/chromium( 5322): [INFO:CONSOLE(9)] "Uncaught SecurityError: Failed to read the 'cookie' property from 'Document': Cookies are disabled inside 'data:' URLs.", source: https://assets.swarmcdn.com/cross/swarmcdn.js?v=4f42193d (9)

import 'dart:convert';
import 'dart:developer';

import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:meme/core/app_theme/app_theme.dart';
import 'package:webview_flutter/webview_flutter.dart';

class TestSwarmVideo extends StatefulWidget {
  const TestSwarmVideo({super.key});

  @override
  State<TestSwarmVideo> createState() => _TestSwarmVideoState();
}

class _TestSwarmVideoState extends State<TestSwarmVideo> {
    WebViewController? webViewController;
  InAppWebViewController? webView;
    @override
  void initState() {
    webViewController = WebViewController()
  ..setJavaScriptMode(JavaScriptMode.unrestricted)
  
  ..setBackgroundColor(const Color(0x00000000))
  ..setNavigationDelegate(
    NavigationDelegate(
      onProgress: (int progress) {
        // Update loading bar.
      },
      onPageStarted: (String url) {
     
      },
      onPageFinished: (String url) {},
      onWebResourceError: (WebResourceError error) {
        log(error.toString());
      },
      onNavigationRequest: (NavigationRequest request) {
        
        return NavigationDecision.navigate;
      },
    ),
  )
  
  ..loadRequest(Uri.parse(videoPage()));
  
    super.initState();
  }


  @override
  Widget build(BuildContext context) {
   
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Meem',
      theme: CustomTheme.themeData,
  
          
       
      home:     Scaffold(
      appBar: AppBar(),
      body:
      
       InAppWebView(
      
                initialData: InAppWebViewInitialData(data:'''
 <!DOCTYPE html>
    <html lang="en">
      <head>
        <!-- ... other meta tags and head content ... -->
      </head>
      <body>
      <h1>  Test Test  </h1> 

    
        <smartvideo
          class="swarm-fluid"
          controls
          playsinline
          width="420" height="315"
          src="swarmify://1948d07135515f5d1841d5f27b5bdd2df16a97d10662e9d88f8b63ba898c6218"
        >
        </smartvideo>

       <h1>  Video Ends Here  </h1> 

       
 <script data-cfasync="false">
    var swarmoptions = {
        swarmcdnkey: "xxxxxxxxxxxxxxx",
        iframeReplacement: "iframe",
        autoreplace: {
            youtube: false
        }
    };
</script>

<script async data-cfasync="false" src="https://assets.swarmcdn.com/cross/swarmdetect.js"></script>

      </body>
    </html>

''',baseUrl:  Uri.dataFromString("https://assets.swarmcdn.com/cross/swarmdetect.js") ),
        
            initialOptions: InAppWebViewGroupOptions(
              
              crossPlatform: InAppWebViewOptions(
                cacheEnabled: false,
                 javaScriptCanOpenWindowsAutomatically: true,
                 allowFileAccessFromFileURLs: true,
                 allowUniversalAccessFromFileURLs: true
              )
            ),
            onWebViewCreated: (InAppWebViewController controller) {
  
           
              webView = controller;
            
              
              
             
            },
           onLoadStart: (controller, url) {
           
           },
            onLoadStop:(controller, url) {
                
            },
          
          
          ))
      
      //   WebViewWidget(controller: webViewController!)),  
   // const MyHomePage(title: 'الخط العربي'),
    );
              }
       
          
      
    
 

}

I tried to add the video player and expected that it work successfully as vimeo and youtube

0 Answers0