Git Product home page Git Product logo

flutter_cached_video_player's Introduction

Cached Video Player

A flutter plugin that has been forked from the official video_player package except that it supports caching in Android and iOS. Web plugin will work like official video_player i.e. without caching support.

Installation

First, add cached_video_player as a dependency in your pubspec.yaml file.

Follow the Android and iOS configuration steps of the official video_player package. This plugin won't work in Desktop.

Issues

  • maxFileSize and maxCacheSize are hardcoded at 100MiB and 1GiB respectively in Android.

Contributors

flutter_cached_video_player's People

Contributors

ciriousjoker avatar desno365 avatar endertan avatar filippo-orru avatar vikram25897 avatar zxhwyp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flutter_cached_video_player's Issues

macOS support

on pub.dev it shows it supports macOS, but does it? if so when?

build apk went wrong

Hello, I meet a question as below. I try to update the 'ext.kotlin_version' as the latest-version but it failed.

What went wrong:
Execution failed for task ':cached_video_player:verifyReleaseResources'.

A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
Android resource linking failed
ERROR:/Users/suchengyu/.gradle/caches/transforms-3/5e083c06c9925c2309f02468fc66e376/transformed/core-1.7.0/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.

Flutter Fix [!] Your project requires a newer version of the Kotlin Gradle plugin. Find the latest version on https://kotlinlang.org/docs/releases.html#release-details, then update /Users/suchengyu/Documents/Github/zilvbang_flutter/android/build.gradle: ext.kotlin_version = '<latest-version>'

How can i delete a cached video

I have tried to delete cached video but i cannot find the method or function for this. I have asked in stack overflow and have gotten 0 suggestions.
Any suggestions will be appreciated thank you

Mute unmute video in loop

Is there a way to add the mute and unmute function without stopping the video and restarting it?


import 'package:cached_video_player/cached_video_player.dart';
import 'package:flutter/material.dart';
import 'package:visibility_detector/visibility_detector.dart';

class VideoClip extends StatefulWidget {
final String url;

const VideoClip({Key key, this.url}) : super(key: key);
@OverRide
_VideoClipState createState() => _VideoClipState();
}

class _VideoClipState extends State {
CachedVideoPlayerController controller;

bool showController = false;

@OverRide
void initState() {
controller = CachedVideoPlayerController.network(widget.url);
controller.initialize().then((_) {
setState(() {});
controller.setLooping(true);
controller.play();
controller.setVolume(0);
});
super.initState();
print("Controller **************" + controller.toString());
print("url *****************" + widget.url);
}

@OverRide
void dispose() {
super.dispose();
controller.dispose();
}

@OverRide
Widget build(BuildContext context) {
return Stack(
alignment: Alignment.topLeft,
children: [

VisibilityDetector(
key: Key("unique key"),
onVisibilityChanged: (VisibilityInfo info) {
debugPrint("${info.visibleFraction} of my widget is visible");
if(info.visibleFraction == 2.0){
controller.play();
controller.setVolume(0);
}
else{
controller.play();
controller.setVolume(0);
}
},
child:
GestureDetector(
onTap: () {
setState(() {
if (controller.value.isPlaying) {
controller.pause();
controller.setVolume(0);
} else {
controller.play();
controller.setVolume(1);

          }
          
        });
      },
      child:
    Container(
      constraints: BoxConstraints(
          minHeight: 370, minWidth: double.infinity, ),
      color: Colors.transparent,
      child:
    Center(
      child: controller.value.initialized
          ? AspectRatio(
              aspectRatio: controller.value.aspectRatio,
              child: CachedVideoPlayer(controller),
            )
          : CircularProgressIndicator(
             strokeWidth: 2.0,
             ),
    ),
    ),
    ),

),
Positioned.fill(
child: Container(
alignment: Alignment.topLeft,
child:

        AnimatedOpacity(
  opacity: controller.value.isPlaying ? 0.0 : 1.0,
  duration: Duration(milliseconds: 500),
  child:
      Container(
      decoration: new BoxDecoration(
        color: new Color.fromRGBO(0, 0, 0, 0.66),
        borderRadius: BorderRadius.circular(50),
      ),
      width: 25,
      height: 25,
      margin: EdgeInsets.only(left: 14.5, top: 14.5),
      child: Icon(
        controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
        color: Color.fromRGBO(255, 255, 255, 0.96),
        size: 15,
      ),
    ),
      
    )

  )
    ),
  ],
);

}
}

using cached_video_player in pageview.builder

First of all, appreciate for your effort!

I am wondering is it working right in my app.
I am using pageview.builder and there are several short videos in each page.
However, I cannot feel the difference between using original video_player and this package.

I thought, video which I watched should be cached, so even if swiped to another page the videos that i watched should be loaded instantly because they are cached. However, videos I watched are loading as same when I used normal video_player.

Am I thinking wrong? How can I test if videos are really cached?

Migrate to null safety

Can you guys pleasee migrate this library to null safety ? i have some project that implement this library. now my client comeback again to improve the projcet but since this lib not migrated yet, i cannot continue the project. Thanks

Failed to load video: 网络连接已中断

My project use video_player , it can play normally , but it can not play when use cache_video_play and throw an exception . this is error info.

[VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: PlatformException(VideoError, Failed to load video: 网络连接已中断。, null, null)

image
image

And this is logs.

server===http://localhost:80/
2021-09-01 16:01:46.550019+0800 Runner[27404:2420989] URLString===http://localhost:80/request.mp4?url=https%3A%2F%2Fmisc.hnxgwh.com.cn%2Fupload%2Fmedia%2F2108%2Fc3e9d6a3e400000.mp4
2021-09-01 16:01:46.550122+0800 Runner[27404:2420989] proxyURL===https://misc.hnxgwh.com.cn/upload/media/2108/c3e9d6a3e400000.mp4
2021-09-01 16:01:48.705840+0800 Runner[27404:2421136] [VERBOSE-2:ui_dart_state.cc(199)] Unhandled Exception: PlatformException(VideoError, Failed to load video: 网络连接已中断。, null, null)

Option to disable caching

I'd like to disable the caching for individual videos like this:

CachedVideoPlayerController.network(
  url,
  useCache: false,
);

This would also be a workaround for:

MacOS support?

I tried to use this in a macOS Flutter app, but when it tried to run "pod install" the following error popped up:

$ pod install
Analyzing dependencies
[!] No podspec found for `cached_video_player` in `Flutter/ephemeral/.symlinks/plugins/cached_video_player/macos`

I have this in my pubspec.yaml:

environment:
  sdk: ">=2.2.2 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  cached_video_player: ^1.0.3

Failed to initialize decoder: OMX.qcom.video.decoder.avc

None of the videos load in any screen. Restarting the app fixes the issue.
This issue is not permanent. It pops up every now and then after using the app for some time.

I/ExoPlayerImpl( 9860): Init c570691 [ExoPlayerLib/2.9.6] [whyred, Redmi Note 5 Pro, Xiaomi, 28]
I/OMXClient( 9860): IOmx service obtained
E/ACodec  ( 9860): Unable to instantiate codec 'OMX.qcom.video.decoder.avc' with err 0xfffffff4.
E/ACodec  ( 9860): signalError(omxError 0xfffffff4, internalError -12)
E/MediaCodec( 9860): Codec reported err 0xfffffff4, actionCode 0, while in state 1
I/flutter ( 9860): UPDATED 5f13415a2bd6073e1d88b948 IN DATABASE
W/MediaCodec-JNI( 9860): try to release MediaCodec from JMediaCodec::~JMediaCodec()...
W/MediaCodec-JNI( 9860): done releasing MediaCodec from JMediaCodec::~JMediaCodec().
W/MediaCodecRenderer( 9860): Failed to initialize decoder: OMX.qcom.video.decoder.avc
W/MediaCodecRenderer( 9860): android.media.MediaCodec$CodecException: Failed to initialize OMX.qcom.video.decoder.avc, error 0xfffffff4
W/MediaCodecRenderer( 9860):    at android.media.MediaCodec.native_setup(Native Method)
W/MediaCodecRenderer( 9860):    at android.media.MediaCodec.<init>(MediaCodec.java:1811)
W/MediaCodecRenderer( 9860):    at android.media.MediaCodec.createByCodecName(MediaCodec.java:1792)
W/MediaCodecRenderer( 9860):    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:802)
W/MediaCodecRenderer( 9860):    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodecWithFallback(MediaCodecRenderer.java:745)
W/MediaCodecRenderer( 9860):    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:474)
W/MediaCodecRenderer( 9860):    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.reinitializeCodec(MediaCodecRenderer.java:1261)
W/MediaCodecRenderer( 9860):    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1111)
W/MediaCodecRenderer( 9860):    at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:552)
W/MediaCodecRenderer( 9860):    at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:647)
W/MediaCodecRenderer( 9860):    at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:529)
W/MediaCodecRenderer( 9860):    at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:300)
W/MediaCodecRenderer( 9860):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/MediaCodecRenderer( 9860):    at android.os.Looper.loop(Looper.java:201)
W/MediaCodecRenderer( 9860):    at android.os.HandlerThread.run(HandlerThread.java:65)
E/ExoPlayerImplInternal( 9860): Playback error.
E/ExoPlayerImplInternal( 9860): com.google.android.exoplayer2.ExoPlaybackException: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.avc, Format(1, null, null, video/avc, null, -1, null, [480, 854, -1.0], [-1, -1])
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:479)
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.reinitializeCodec(MediaCodecRenderer.java:1261)
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.onInputFormatChanged(MediaCodecRenderer.java:1111)
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.video.MediaCodecVideoRenderer.onInputFormatChanged(MediaCodecVideoRenderer.java:552)
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.render(MediaCodecRenderer.java:647)
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:529)
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:300)
E/ExoPlayerImplInternal( 9860):         at android.os.Handler.dispatchMessage(Handler.java:102)
E/ExoPlayerImplInternal( 9860):         at android.os.Looper.loop(Looper.java:201)
E/ExoPlayerImplInternal( 9860):         at android.os.HandlerThread.run(HandlerThread.java:65)
E/ExoPlayerImplInternal( 9860): Caused by: com.google.android.exoplayer2.mediacodec.MediaCodecRenderer$DecoderInitializationException: Decoder init failed: OMX.qcom.video.decoder.avc, Format(1, null, null, video/avc, null, -1, null, [480, 854, -1.0], [-1, -1])
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodecWithFallback(MediaCodecRenderer.java:753)
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.maybeInitCodec(MediaCodecRenderer.java:474)
E/ExoPlayerImplInternal( 9860):         ... 9 more
E/ExoPlayerImplInternal( 9860): Caused by: android.media.MediaCodec$CodecException: Failed to initialize OMX.qcom.video.decoder.avc, error 0xfffffff4
E/ExoPlayerImplInternal( 9860):         at android.media.MediaCodec.native_setup(Native Method)
E/ExoPlayerImplInternal( 9860):         at android.media.MediaCodec.<init>(MediaCodec.java:1811)
E/ExoPlayerImplInternal( 9860):         at android.media.MediaCodec.createByCodecName(MediaCodec.java:1792)
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodec(MediaCodecRenderer.java:802)
E/ExoPlayerImplInternal( 9860):         at com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.initCodecWithFallback(MediaCodecRenderer.java:745)
E/ExoPlayerImplInternal( 9860):         ... 10 more

Where videos save

I want to add a download options so I am thinking of copying the file from cache.Can you please tell me how to copy or how to get the cache path.

audiomixing with other video

when i play a video works fine.But when i play a video in pageview and scroll down to other video it mix the audio with my upper video is their any focus methord.

Some questions

1 How to get the download progress ?
2 Can I delete the Android or iOS cache and how to do it
3. For example, I loaded a network video, the first time DataSourceType.network I think it is correct

Then I restarted the app and printed DataSourceTyp == network again. I think it should be file
Because the second startup video has been downloaded, it should be taken from the cache, I don't know if it's right

Preload next video

Hi, thanks for a great player, I have below query

Is there a way to preload next videos.

I am getting this error, while run the application.

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':cached_video_player:compileDebugJavaWithJavac'.

Could not resolve all files for configuration ':cached_video_player:debugCompileClasspath'.
Failed to transform flutter_embedding_debug-1.0.0-d1bc06f032f9d6c148ea6b96b48261d6f545004f.jar (io.flutter:flutter_embedding_debug:1.0.0-d1bc06f032f9d6c148ea6b96b48261d6f545004f) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for JetifyTransform: C:\Users\Sanjay Ramani.gradle\caches\modules-2\files-2.1\io.flutter\flutter_embedding_debug\1.0.0-d1bc06f032f9d6c148ea6b96b48261d6f545004f\d413186ad73c0653d1d500fc2b85eac24280a0dd\flutter_embedding_debug-1.0.0-d1bc06f032f9d6c148ea6b96b48261d6f545004f.jar.
> Cannot parse result path string:

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 28s
Exception: Gradle task assembleDebug failed with exit code 1

Cached video player not working ExoPlayer class not found please help

E/AndroidRuntime( 526): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/exoplayer2/ExoPlayerFactory;
E/AndroidRuntime( 526): at com.lazyarts.vikram.cached_video_player.CachedVideoPlayerPlugin$VideoPlayer.(CachedVideoPlayerPlugin.java:82)
E/AndroidRuntime( 526): at com.lazyarts.vikram.cached_video_player.CachedVideoPlayerPlugin.onMethodCall(CachedVideoPlayerPlugin.java:349)
E/AndroidRuntime( 526): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/AndroidRuntime( 526): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/AndroidRuntime( 526): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/AndroidRuntime( 526): at android.os.MessageQueue.nativePollOnce(Native Method)
E/AndroidRuntime( 526): at android.os.MessageQueue.next(MessageQueue.java:336)
E/AndroidRuntime( 526): at android.os.Looper.loop(Looper.java:197)
E/AndroidRuntime( 526): at android.app.ActivityThread.main(ActivityThread.java:7807)
E/AndroidRuntime( 526): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 526): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/AndroidRuntime( 526): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1047)
E/AndroidRuntime( 526): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.exoplayer2.ExoPlayerFactory" on path: DexPathList[[zip file "/data/app/com.arraypointer.india_learner-e1xlBXMLbGtvIS6vtN_Ilw==/base.apk"],nativeLibraryDirectories=[/data/app/com.arraypointer.india_learner-e1xlBXMLbGtvIS6vtN_Ilw==/lib/arm64, /data/app/com.arraypointer.india_learner-e1xlBXMLbGtvIS6vtN_Ilw==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
E/AndroidRuntime( 526): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
E/AndroidRuntime( 526): at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
E/AndroidRuntime( 526): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/AndroidRuntime( 526): ... 12 more

Fatal problem. The app is exited after opening

The old version 1.03 is good, but there is a fatal problem after upgrading the new version 2.2. The app exits after opening. The cache of 2.0.0-dev.1 doesn't work at all. It will be downloaded repeatedly, and others feedback that the cache is invalid. My pubspec.yaml does not contain the official video player, but I found that the official inventory lies in the external library, so I guess it is included in other plug-ins, resulting in conflicts. I can't use any version of video cache now. Please help us upgrade and resolve this fatal issue. Thank you for your hard work

Add pre-cache functionality.

Adding a preCache to this package will help to avoid caching the whole video. Take for instance social media apps that has a lot of videos to be played and caching all these videos will affect the memory and performance of the app and device.

preCache will help to just cache only amount of video time like preCaching for 10 secs as video download.

Update please as possibel as

I think you need to update this pluging. Please Update

The plugin cached_video_player uses a deprecated version of the Android embedding. To avoid unexpected runtime failures or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs. If you are a plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

Video doesn't cache

I tried the normal video player and the cached video player and there's no difference between them at all, video still download everytime especially when autoloop is set to true.
Please I need a fix on this

The plugins `cached_video_player` use a deprecated version of the Android embedding.

With the new flutter version 2.5.0 i am getting this after running flutter pub get:

Running "flutter pub get" in hyll-mobile... 4.9s
The plugins cached_video_playerk use a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

About the maxFileSize

What do you mean by the max file size? You mean the maximum size of the file that can be cached? if the file size is greater than 100MB will I still be able to play the video?
Thank you

Everytime throws exception in IOS and crashes the app on start - v2.0.0-dev.1

Exception:

*** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Duplicate plugin key: FLTVideoPlayerPlugin’
terminating with uncaught exception of type NSException

Package Version: 2.0.0-dev.1

I was initially using 1.0.3 but that suddenly started throwing class not found exception for ExoPlayer.

optimization

Its taking too much time while loading video 1st time , how we can improve it?

its working similar to video_player no video caching

I used this package before the cached_video_player: ^1.0.3 version it was working fine but in my null safety project I have tried a new beta version 2.0.0-dev.1 but it's the same as like video player, not caching any video, its downloading again and again. I have tried on the released version but it's not working, can somebody help me out? @vikram25897

Migration guide

Hi everyone, if you are migrating to the pre-release, make sure you change all your instances of CachedVideoPlayerController to just VideoPlayerController. They renamed it. Opening this issue until they write a short migration guide into the new README so other people can figure it out easily.

Easy to do:
image

web

how can I use this on web and mobile
it dose not initial on web.
is that any solution for play on web?

0

0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.