Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: broken vimeo api requests and upgraded the dependencies #187

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -98,7 +98,7 @@ This plugin built upon flutter's official [`video_player`](https://pub.dartlang.

---

- On mobile full screen
- On mobile full-screen

---

Expand Down
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
17 changes: 9 additions & 8 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
8 changes: 4 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 3 additions & 1 deletion example/macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import FlutterMacOS
import Foundation

import package_info_plus
import video_player_avfoundation
import wakelock_plus

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
FVPVideoPlayerPlugin.register(with: registry.registrar(forPlugin: "FVPVideoPlayerPlugin"))
WakelockPlusMacosPlugin.register(with: registry.registrar(forPlugin: "WakelockPlusMacosPlugin"))
}
52 changes: 52 additions & 0 deletions example/macos/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
PODS:
- FlutterMacOS (1.0.0)
- media_kit_libs_macos_video (1.0.4):
- FlutterMacOS
- media_kit_native_event_loop (1.0.0):
- FlutterMacOS
- media_kit_video (0.0.1):
- FlutterMacOS
- package_info_plus (0.0.1):
- FlutterMacOS
- screen_brightness_macos (0.1.0):
- FlutterMacOS
- wakelock_plus (0.0.1):
- FlutterMacOS

DEPENDENCIES:
- FlutterMacOS (from `Flutter/ephemeral`)
- media_kit_libs_macos_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos`)
- media_kit_native_event_loop (from `Flutter/ephemeral/.symlinks/plugins/media_kit_native_event_loop/macos`)
- media_kit_video (from `Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos`)
- package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`)
- screen_brightness_macos (from `Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos`)
- wakelock_plus (from `Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos`)

EXTERNAL SOURCES:
FlutterMacOS:
:path: Flutter/ephemeral
media_kit_libs_macos_video:
:path: Flutter/ephemeral/.symlinks/plugins/media_kit_libs_macos_video/macos
media_kit_native_event_loop:
:path: Flutter/ephemeral/.symlinks/plugins/media_kit_native_event_loop/macos
media_kit_video:
:path: Flutter/ephemeral/.symlinks/plugins/media_kit_video/macos
package_info_plus:
:path: Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos
screen_brightness_macos:
:path: Flutter/ephemeral/.symlinks/plugins/screen_brightness_macos/macos
wakelock_plus:
:path: Flutter/ephemeral/.symlinks/plugins/wakelock_plus/macos

SPEC CHECKSUMS:
FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24
media_kit_libs_macos_video: b3e2bbec2eef97c285f2b1baa7963c67c753fb82
media_kit_native_event_loop: 81fd5b45192b72f8b5b69eaf5b540f45777eb8d5
media_kit_video: c75b07f14d59706c775778e4dd47dd027de8d1e5
package_info_plus: 02d7a575e80f194102bef286361c6c326e4c29ce
screen_brightness_macos: 2d6d3af2165592d9a55ffcd95b7550970e41ebda
wakelock_plus: 4783562c9a43d209c458cb9b30692134af456269

PODFILE CHECKSUM: 353c8bcc5d5b0994e508d035b5431cfe18c1dea7

COCOAPODS: 1.11.2
61 changes: 37 additions & 24 deletions lib/src/utils/video_apis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,43 @@ class VideoApis {
) async {
try {
final response = await _makeRequestHash(videoId, hash);
final jsonData = jsonDecode(response.body)['request']['files']
['progressive'] as List<dynamic>;
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<dynamic> rawStreamUrls =
(dashData['streams'] as List<dynamic>?) ?? <dynamic>[];

final List<VideoQalityUrls> 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(
Expand All @@ -77,7 +89,8 @@ class VideoApis {
Uri.parse('https://api.vimeo.com/videos/$videoId'),
headers: httpHeader,
);
final jsonData = jsonDecode(response.body)['files'] as List<dynamic>;
final jsonData =
(jsonDecode(response.body)['files'] as List<dynamic>?) ?? [];

final List<VideoQalityUrls> list = [];
for (int i = 0; i < jsonData.length; i++) {
Expand Down
14 changes: 7 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading