From e40799b35175e03fe3f51c8b1df2961ed24d59c8 Mon Sep 17 00:00:00 2001 From: newtaDev Date: Thu, 11 Apr 2024 09:49:40 +0530 Subject: [PATCH] fix: broken vimeo api requests and upgraded the dependencies --- README.md | 14 ++--- example/ios/Flutter/AppFrameworkInfo.plist | 2 +- example/ios/Podfile | 2 +- example/ios/Podfile.lock | 17 +++--- example/ios/Runner.xcodeproj/project.pbxproj | 8 +-- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../Flutter/GeneratedPluginRegistrant.swift | 4 +- example/macos/Podfile.lock | 52 ++++++++++++++++ lib/src/utils/video_apis.dart | 61 +++++++++++-------- pubspec.yaml | 14 ++--- 10 files changed, 122 insertions(+), 54 deletions(-) create mode 100644 example/macos/Podfile.lock diff --git a/README.md b/README.md index 4dd4015c..e5515225 100644 --- a/README.md +++ b/README.md @@ -39,24 +39,24 @@ This plugin built upon flutter's official [`video_player`](https://pub.dartlang. - Custom progress bar - Custom labels - `Change video quality` (for vimeo and youtube) -- Enable/disable fullscreen player +- Enable/disable full-screen player - support for live youtube video - [TODO] support for video playlist ## Features on web -- Double tap on Video player to enable/disable fullscreen -- `Mute/unmute` volume +- Double tap on Video player to enable/disable full-screen +- `Mute/unMute` volume - Video player integration with keyboard - `SPACE` play/pause video - `M` mute/unMute video - - `F` enable/disable fullscreen - - `ESC` enable/disable fullscreen + - `F` enable/disable full-screen + - `ESC` enable/disable full-screen - `->` seek video forward - `<-` seek video backward -- Double tap on video (enable/diables fullscreen) +- Double tap on video (enable/disables full-screen) ## Demo @@ -98,7 +98,7 @@ This plugin built upon flutter's official [`video_player`](https://pub.dartlang. --- -- On mobile full screen +- On mobile full-screen --- diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist index 9625e105..7c569640 100644 --- a/example/ios/Flutter/AppFrameworkInfo.plist +++ b/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 11.0 + 12.0 diff --git a/example/ios/Podfile b/example/ios/Podfile index 88359b22..279576f3 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -# platform :ios, '11.0' +# platform :ios, '12.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 2d8232cd..9e54c99f 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -4,13 +4,14 @@ PODS: - Flutter - video_player_avfoundation (0.0.1): - Flutter + - FlutterMacOS - wakelock_plus (0.0.1): - Flutter DEPENDENCIES: - Flutter (from `Flutter`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/ios`) + - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`) - wakelock_plus (from `.symlinks/plugins/wakelock_plus/ios`) EXTERNAL SOURCES: @@ -19,16 +20,16 @@ EXTERNAL SOURCES: package_info_plus: :path: ".symlinks/plugins/package_info_plus/ios" video_player_avfoundation: - :path: ".symlinks/plugins/video_player_avfoundation/ios" + :path: ".symlinks/plugins/video_player_avfoundation/darwin" wakelock_plus: :path: ".symlinks/plugins/wakelock_plus/ios" SPEC CHECKSUMS: - Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - package_info_plus: fd030dabf36271f146f1f3beacd48f564b0f17f7 - video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126 - wakelock_plus: 8b09852c8876491e4b6d179e17dfe2a0b5f60d47 + Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 + package_info_plus: 58f0028419748fad15bf008b270aaa8e54380b1c + video_player_avfoundation: 02011213dab73ae3687df27ce441fbbcc82b5579 + wakelock_plus: 78ec7c5b202cab7761af8e2b2b3d0671be6c4ae1 -PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 +PODFILE CHECKSUM: c4c93c5f6502fe2754f48404d3594bf779584011 -COCOAPODS: 1.11.2 +COCOAPODS: 1.15.2 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 5b1c9f9c..325aea03 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -155,7 +155,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -342,7 +342,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; @@ -420,7 +420,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -469,7 +469,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 11.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a3..5e31d3d3 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ ; - final progressiveUrls = List.generate( - jsonData.length, - (index) => VideoQalityUrls( - quality: int.parse( - (jsonData[index]['quality'] as String?)?.split('p').first ?? '0', - ), - url: jsonData[index]['url'] as String, - ), - ); - if (progressiveUrls.isEmpty) { - final jsonRes = - jsonDecode(response.body)['request']['files']['hls']['cdns']; - for (final element in (jsonRes as Map).entries.toList()) { - progressiveUrls.add( - VideoQalityUrls( - quality: 720, - url: element.value['url'] as String, + final jsonData = jsonDecode(response.body)['request']['files']; + final dashData = jsonData['dash']; + final hlsData = jsonData['hls']; + final defaultCDN = hlsData['default_cdn']; + final cdnVideoUrl = (hlsData['cdns'][defaultCDN]['url'] as String?) ?? ''; + final List rawStreamUrls = + (dashData['streams'] as List?) ?? []; + + final List vimeoQualityUrls = []; + + for (final item in rawStreamUrls) { + final sepList = cdnVideoUrl.split('/sep/video/'); + final firstUrlPiece = sepList.firstOrNull ?? ''; + final lastUrlPiece = + ((sepList.lastOrNull ?? '').split('/').lastOrNull) ?? + (sepList.lastOrNull ?? ''); + final String urlId = + ((item['id'] ?? '') as String).split('-').firstOrNull ?? ''; + vimeoQualityUrls.add( + VideoQalityUrls( + quality: int.parse( + (item['quality'] as String?)?.split('p').first ?? '0', ), - ); - break; - } + url: '$firstUrlPiece/sep/video/$urlId/$lastUrlPiece', + ), + ); } - return progressiveUrls; + if (vimeoQualityUrls.isEmpty) { + vimeoQualityUrls.add( + VideoQalityUrls( + quality: 720, + url: cdnVideoUrl, + ), + ); + } + + return vimeoQualityUrls; } catch (error) { if (error.toString().contains('XMLHttpRequest')) { log( @@ -77,7 +89,8 @@ class VideoApis { Uri.parse('https://api.vimeo.com/videos/$videoId'), headers: httpHeader, ); - final jsonData = jsonDecode(response.body)['files'] as List; + final jsonData = + (jsonDecode(response.body)['files'] as List?) ?? []; final List list = []; for (int i = 0; i < jsonData.length; i++) { diff --git a/pubspec.yaml b/pubspec.yaml index 88647f4e..e4f7d6d4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -4,19 +4,19 @@ version: 0.2.1 homepage: https://github.com/newtaDev/pod_player environment: - sdk: ">=2.17.0 <4.0.0" + sdk: ">=3.0.0 <4.0.0" flutter: ">=1.17.0" dependencies: flutter: sdk: flutter # services - video_player: ^2.7.0 - http: ^1.1.0 - get: ^4.6.5 - wakelock_plus: ^1.1.1 - universal_html: ^2.2.3 - youtube_explode_dart: ^2.0.1 + video_player: ^2.8.5 + http: ^1.2.1 + get: ^4.6.6 + wakelock_plus: ^1.2.4 + universal_html: ^2.2.4 + youtube_explode_dart: ^2.2.0 dev_dependencies: flutter_test: