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

[Feature Request]: Make Local API work in Cordova #5

Closed
2 tasks done
MarmadileManteater opened this issue Jun 6, 2022 · 8 comments
Closed
2 tasks done

[Feature Request]: Make Local API work in Cordova #5

MarmadileManteater opened this issue Jun 6, 2022 · 8 comments
Assignees
Labels
bug Something isn't working E: improvement existing feature enhancement New feature or request

Comments

@MarmadileManteater
Copy link
Owner

Guidelines

  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.
  • I have searched the documentation for information that matches the description of the feature request I want to file, without success.

Problem Description

Local API does not work because of CORS.

Proposed Solution

I could integrate a Cordova plugin into the application, so that the app can make http requests through OS level APIs exposed through the plugin. Then, those requests wouldn't have to worry about the CORS.

Alternatives Considered

This might also not be a problem. The invidious API works very well, and it might also just be good enough for stability to allow multiple invidious servers to be designated as fallbacks instead of Local API being a fallback.

Issue Labels

improvement to existing feature

Additional Information

No response

@MarmadileManteater
Copy link
Owner Author

Reading back through my issues, I should also note that there is no real way to fix this issue in the PWA without standing up a server.

@MarmadileManteater
Copy link
Owner Author

I hit another wall with this. I was able to make a proof of concept using the Cordova Advanced HTTP plugin. The issue that completely halted my progress had to do with the <video> tag and the Content-Security-Policy. Even if all of the local API calls are rerouted through OS level API calls, the <video> tag still doesn't seem to be able to get past CORS. I have tried everything in this guide with no success.

@MarmadileManteater MarmadileManteater added the bug Something isn't working label Aug 19, 2022
@github-actions
Copy link

github-actions bot commented Oct 9, 2022

This issue is stale because it has been open 28 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@ChunkyProgrammer
Copy link

ChunkyProgrammer commented Jan 10, 2023

There is a setting for proxying videos through invidious regardless of api preference that you could force to be true if that's the only thing that you had issues with

MarmadileManteater added a commit that referenced this issue Jan 27, 2023
This implementation maps the fetch function used by YouTube.js to
the `cordova-advanced-http-plugin`.
This is related to #5.
MarmadileManteater added a commit that referenced this issue Jan 27, 2023
- Add `IS_ELECTRON` checks before accessing the filesystem
- Allow Local API to be used when `IS_CORDOVA` or `IS_ELECTRON`

This is related to #5.
@MarmadileManteater
Copy link
Owner Author

I've made some major progress on this. Since the switch to YouTube.js upstream, I was able to simply override the fetch function and most everything just started working (well except for the parts of Local API which still use yt-channel-info).

There is a setting for proxying videos through invidious regardless of api preference that you could force to be true if that's the only thing that you had issues with

As far as streaming videos is concerned, it is correct that the setting for proxying videos through invidious does work, but I also have made a breakthrough. I have figured out how to asynchronously fetch videos (using the Cordova advanced http plugin) and feed the resulting blob URL back to the video tag. Videojs is a little finicky about the blob url being updated, but the video does actually play. I need to 🧹clean this up, but it looks like Local API in Cordova is totally possible.

MarmadileManteater added a commit that referenced this issue Jan 31, 2023
@MarmadileManteater
Copy link
Owner Author

Since I've been having trouble with stuttering, I am going to refrain with pushing the proxy code for streaming into development, but I am pushing all of the other youtube.js changes into development at this time with the intent to push out a new release soon 🤞 because there is an issue currently preventing invidious being used as a proxy. (basically, the /latest_version endpoint doesn't seem to be respecting the &local=true flag, and that is causing CORS issues), so I think I'm going to release the youtube.js changes along with the fix for CORS issues with invidious in order to make FTcordova more robust overall).

I will keep this issue open and update it as I implement the local API streaming interface so that one day, the local API will be able to be used fully without any need for proxying videos through invidious inside of the APK.

MarmadileManteater added a commit that referenced this issue Jan 30, 2024
Instruct webview to lie that it is `youtube.com`
Pros:
- local api streaming works without `file://` url flag
Cons:
- video urls fetched from invidious are still blocked by CORS
- some urls don't allow youtube.com to fetch them and need to be bypassed by a javascript interface
- it completely breaks browser navigation so that has to be reimplemented in freetube

#5
@MarmadileManteater
Copy link
Owner Author

Local API streaming is now available in the latest nightly. 🍾 🥂

MarmadileManteater added a commit that referenced this issue Apr 4, 2024
##### ~~Cordova~~ Android specific changes:

- Switched away from Cordova [#101](#101 (comment))
  - Added ability to stream videos **locally** *without* proxying through invidious [#5](#5) 🥂
  - Added ability to seek in the media controls notification
  - Fixed videos stopping or stuttering when the app enters the background [#10](#10)
  - Fixed YT links not opening in app [#264](#264)
- Added ability to change where profiles/settings/playlists/history.db are located on the filesystem [#299](#299)
- Fullscreen videos now take up the entire screen instead of sharing real estate with the system UI

This release includes all of the changes from upstream release [0.20.0](https://github.com/FreeTubeApp/FreeTube/releases/tag/v0.20.0-beta).

  ...

  **Full Changelog**: 0.19.2.110...0.20.0.111
MarmadileManteater added a commit that referenced this issue Apr 4, 2024
##### ~~Cordova~~ Android specific changes:

- Switched away from Cordova [#101](#101 (comment))
  - Added ability to stream videos **locally** *without* proxying through invidious [#5](#5) 🥂
  - Added ability to seek in the media controls notification
  - Fixed videos stopping or stuttering when the app enters the background [#10](#10)
  - Fixed YT links not opening in app [#264](#264)
- Added ability to change where profiles/settings/playlists/history.db are located on the filesystem [#299](#299)
- Fullscreen videos now take up the entire screen instead of sharing real estate with the system UI

This release includes all of the changes from upstream release [0.20.0](https://github.com/FreeTubeApp/FreeTube/releases/tag/v0.20.0-beta).

  ...

  **Full Changelog**: 0.19.2.110...0.20.0.111
MarmadileManteater added a commit that referenced this issue Apr 4, 2024
##### ~~Cordova~~ Android specific changes:

- Switched away from Cordova [#101](#101 (comment))
  - Added ability to stream videos **locally** *without* proxying through invidious [#5](#5) 🥂
  - Added ability to seek in the media controls notification
  - Fixed videos stopping or stuttering when the app enters the background [#10](#10)
  - Fixed YT links not opening in app [#264](#264)
- Added ability to change where profiles/settings/playlists/history.db are located on the filesystem [#299](#299)
- Fullscreen videos now take up the entire screen instead of sharing real estate with the system UI

This release includes all of the changes from upstream release [0.20.0](https://github.com/FreeTubeApp/FreeTube/releases/tag/v0.20.0-beta).

  ...

  **Full Changelog**: 0.19.2.110...0.20.0.113
MarmadileManteater added a commit that referenced this issue Apr 4, 2024
##### ~~Cordova~~ Android specific changes:

- Switched away from Cordova [#101](#101 (comment))
  - Added ability to stream videos **locally** *without* proxying through invidious [#5](#5) 🥂
  - Added ability to seek in the media controls notification
  - Fixed videos stopping or stuttering when the app enters the background [#10](#10)
  - Fixed YT links not opening in app [#264](#264)
- Added ability to change where profiles/settings/playlists/history.db are located on the filesystem [#299](#299)
- Fullscreen videos now take up the entire screen instead of sharing real estate with the system UI

This release includes all of the changes from upstream release [0.20.0](https://github.com/FreeTubeApp/FreeTube/releases/tag/v0.20.0-beta).

  ...

  **Full Changelog**: 0.19.2.110...0.20.0.114
MarmadileManteater added a commit that referenced this issue Apr 4, 2024
##### ~~Cordova~~ Android specific changes:

- Switched away from Cordova [#101](#101 (comment))
  - Added ability to stream videos **locally** *without* proxying through invidious [#5](#5) 🥂
  - Added ability to seek in the media controls notification
  - Fixed videos stopping or stuttering when the app enters the background [#10](#10)
  - Fixed YT links not opening in app [#264](#264)
- Added ability to change where profiles/settings/playlists/history.db are located on the filesystem [#299](#299)
- Fullscreen videos now take up the entire screen instead of sharing real estate with the system UI

This release includes all of the changes from upstream release [0.20.0](https://github.com/FreeTubeApp/FreeTube/releases/tag/v0.20.0-beta).

  ...

  **Full Changelog**: 0.19.2.110...0.20.0.115
@MarmadileManteater
Copy link
Owner Author

This is now resolved by release 0.20.0.115.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working E: improvement existing feature enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants