From d9f9edf8a8a4373d7a5df1e80ffdeb8083a08d97 Mon Sep 17 00:00:00 2001 From: Nikita Krupin Date: Tue, 31 May 2022 23:40:36 -0400 Subject: [PATCH] sponsorblock.vue --- NUXT/components/Player/index.vue | 18 +--- NUXT/components/Player/sponsorblock.vue | 43 ++++++++ NUXT/plugins/vuetube.js | 2 +- android/app/src/main/res/xml/config.xml | 4 + .../screenorientation/CDVOrientation.java | 98 +++++++++++++++++++ ios/App/App/config.xml | 4 + ios/App/Podfile | 23 ++--- 7 files changed, 165 insertions(+), 27 deletions(-) create mode 100644 NUXT/components/Player/sponsorblock.vue create mode 100644 android/capacitor-cordova-android-plugins/src/main/java/cordova/plugins/screenorientation/CDVOrientation.java diff --git a/NUXT/components/Player/index.vue b/NUXT/components/Player/index.vue index c2a7eeb..dfdcc3f 100644 --- a/NUXT/components/Player/index.vue +++ b/NUXT/components/Player/index.vue @@ -162,6 +162,7 @@ :controls="controls" @seeking="seeking = !seeking" /> + @@ -176,8 +177,10 @@ import captions from "~/components/Player/captions.vue"; import playpause from "~/components/Player/playpause.vue"; import watchtime from "~/components/Player/watchtime.vue"; import fullscreen from "~/components/Player/fullscreen.vue"; +import sponsorblock from "~/components/Player/sponsorblock.vue"; export default { components: { + sponsorblock, fullscreen, watchtime, playpause, @@ -213,21 +216,6 @@ export default { this.vidSrc = this.sources[this.sources.length - 1].url; // TODO: detect orientation change and enter fullscreen // TODO: detect video loading state and send this.loading to play button :loading = loading - - - this.$youtube.getSponsorBlock(this.$route.query.v, (data) => { - sponsorBlock = data.segment; - }); - - this.$refs.player.ontimeupdate = () => { - let vidTime = this.$refs.player.currentTime; - for (let i = 0; i < sponsorBlock.length; i++) { - if (vidTime > sponsorBlock[i][0] && vidTime < sponsorBlock[0][i]) { - this.$refs.player.currentTime = sponsorBlock[i][0]; - break; - } - } - } }, beforeDestroy() { if (this.isFullscreen) this.exitFullscreen(); diff --git a/NUXT/components/Player/sponsorblock.vue b/NUXT/components/Player/sponsorblock.vue new file mode 100644 index 0000000..a300eb2 --- /dev/null +++ b/NUXT/components/Player/sponsorblock.vue @@ -0,0 +1,43 @@ + + + diff --git a/NUXT/plugins/vuetube.js b/NUXT/plugins/vuetube.js index 018ef5b..36437f5 100644 --- a/NUXT/plugins/vuetube.js +++ b/NUXT/plugins/vuetube.js @@ -149,7 +149,7 @@ const module = { // join the array into a string with : as a separator const returntext = levels.join(":"); - console.log("Human Time:", returntext); + // console.log("Human Time:", returntext); return returntext; }, //--- End Convert Time To Human Readable String ---// diff --git a/android/app/src/main/res/xml/config.xml b/android/app/src/main/res/xml/config.xml index 1b1b0e0..0886a47 100644 --- a/android/app/src/main/res/xml/config.xml +++ b/android/app/src/main/res/xml/config.xml @@ -2,5 +2,9 @@ + + + + \ No newline at end of file diff --git a/android/capacitor-cordova-android-plugins/src/main/java/cordova/plugins/screenorientation/CDVOrientation.java b/android/capacitor-cordova-android-plugins/src/main/java/cordova/plugins/screenorientation/CDVOrientation.java new file mode 100644 index 0000000..5dc845e --- /dev/null +++ b/android/capacitor-cordova-android-plugins/src/main/java/cordova/plugins/screenorientation/CDVOrientation.java @@ -0,0 +1,98 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +package cordova.plugins.screenorientation; + +import org.apache.cordova.CallbackContext; +import org.apache.cordova.CordovaPlugin; + +import org.json.JSONArray; +import org.json.JSONException; + +import android.app.Activity; +import android.content.pm.ActivityInfo; +import android.util.Log; + +public class CDVOrientation extends CordovaPlugin { + + private static final String TAG = "YoikScreenOrientation"; + + /** + * Screen Orientation Constants + */ + + private static final String ANY = "any"; + private static final String PORTRAIT_PRIMARY = "portrait-primary"; + private static final String PORTRAIT_SECONDARY = "portrait-secondary"; + private static final String LANDSCAPE_PRIMARY = "landscape-primary"; + private static final String LANDSCAPE_SECONDARY = "landscape-secondary"; + private static final String PORTRAIT = "portrait"; + private static final String LANDSCAPE = "landscape"; + + @Override + public boolean execute(String action, JSONArray args, CallbackContext callbackContext) { + + Log.d(TAG, "execute action: " + action); + + // Route the Action + if (action.equals("screenOrientation")) { + return routeScreenOrientation(args, callbackContext); + } + + // Action not found + callbackContext.error("action not recognised"); + return false; + } + + private boolean routeScreenOrientation(JSONArray args, CallbackContext callbackContext) { + + String action = args.optString(0); + + + + String orientation = args.optString(1); + + Log.d(TAG, "Requested ScreenOrientation: " + orientation); + + Activity activity = cordova.getActivity(); + + if (orientation.equals(ANY)) { + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + } else if (orientation.equals(LANDSCAPE_PRIMARY)) { + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); + } else if (orientation.equals(PORTRAIT_PRIMARY)) { + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); + } else if (orientation.equals(LANDSCAPE)) { + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); + } else if (orientation.equals(PORTRAIT)) { + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + } else if (orientation.equals(LANDSCAPE_SECONDARY)) { + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); + } else if (orientation.equals(PORTRAIT_SECONDARY)) { + activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); + } + + callbackContext.success(); + return true; + + + } +} \ No newline at end of file diff --git a/ios/App/App/config.xml b/ios/App/App/config.xml index 1b1b0e0..b43c248 100644 --- a/ios/App/App/config.xml +++ b/ios/App/App/config.xml @@ -2,5 +2,9 @@ + + + + \ No newline at end of file diff --git a/ios/App/Podfile b/ios/App/Podfile index d3fc14a..323ce86 100644 --- a/ios/App/Podfile +++ b/ios/App/Podfile @@ -9,17 +9,18 @@ install! 'cocoapods', :disable_input_output_paths => true def capacitor_pods pod 'Capacitor', :path => '../../node_modules/@capacitor/ios' pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios' - pod 'CapacitorCommunityHttp', :path => '..\..\node_modules\@capacitor-community\http' - pod 'CapacitorApp', :path => '..\..\node_modules\@capacitor\app' - pod 'CapacitorBrowser', :path => '..\..\node_modules\@capacitor\browser' - pod 'CapacitorDevice', :path => '..\..\node_modules\@capacitor\device' - pod 'CapacitorFilesystem', :path => '..\..\node_modules\@capacitor\filesystem' - pod 'CapacitorHaptics', :path => '..\..\node_modules\@capacitor\haptics' - pod 'CapacitorShare', :path => '..\..\node_modules\@capacitor\share' - pod 'CapacitorSplashScreen', :path => '..\..\node_modules\@capacitor\splash-screen' - pod 'CapacitorStatusBar', :path => '..\..\node_modules\@capacitor\status-bar' - pod 'CapacitorToast', :path => '..\..\node_modules\@capacitor\toast' - pod 'HugotomaziCapacitorNavigationBar', :path => '..\..\node_modules\@hugotomazi\capacitor-navigation-bar' + pod 'CapacitorCommunityHttp', :path => '../../node_modules/@capacitor-community/http' + pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app' + pod 'CapacitorBrowser', :path => '../../node_modules/@capacitor/browser' + pod 'CapacitorDevice', :path => '../../node_modules/@capacitor/device' + pod 'CapacitorFilesystem', :path => '../../node_modules/@capacitor/filesystem' + pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics' + pod 'CapacitorShare', :path => '../../node_modules/@capacitor/share' + pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen' + pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar' + pod 'CapacitorToast', :path => '../../node_modules/@capacitor/toast' + pod 'HugotomaziCapacitorNavigationBar', :path => '../../node_modules/@hugotomazi/capacitor-navigation-bar' + pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins' end target 'App' do