miloproductionsinc / cordova-plugin-chromecast Goto Github PK
View Code? Open in Web Editor NEWThis project forked from jellyfin-archive/cordova-plugin-chromecast
Control Chromecast from Cordova
License: Other
This project forked from jellyfin-archive/cordova-plugin-chromecast
Control Chromecast from Cordova
License: Other
Hello and thanks for this amazing plugin.
I have set it up and got the example with the video and pause/stop working in few minutes.
Unfortunately, that is not the use I would like to achieve: I would need to open a remote URL on the screen. I have found this project that uses Chromecast APIs and works like a charm on their web-example using Chrome browser:
Project: https://github.com/DeMille/url-cast-receiver
Example: https://demille.github.io/url-cast-receiver/
Basically, I would like to achieve that using this plugin.
I have tried to adapt their implementation inside my test cordova app, but I always get issues when calling the requestSession method: the error callback gets triggered, and the error I get is: "namespace 'urn:x-cast:com.url.cast' not founded unverified"
I have tried both using the recommended App ID and namespace from the project, and also tried using one generated by me, but always get that error. After that, it looks like I can no longer close the session, not even force closing the app, so the only way to be able to scan again my Chromecast TV is to uninstall the app and re-install again, but I believe this is only a side effect of the main issue.
Thanks for any hint!
I got a new/old Chromecasts today. My 3rd gen has always worked; the 2nd gen does not.
chrome.cast.cordova.startRouteScan
chrome.cast.cordova.selectRoute
, I get a timeout
Error:Failed to join route (com.google.android.gms/.cast…7acf00xxxxxxxxxxxx) after 15s and 1 tries.
// I know that this repo is unmaintained.
Given this situation:
session.leave
or session.stop
chrome.cast.initialize
againThis is tested in the manual tests on the primary device. The end of tests_manual_primary_1 and
the beginning of tests_manual_primary 2 tests this.
NOTE: The bug lasts longer when doing session.leave
. The bug seems to last until one of 2 things happen:
session.leave
does not kill the session the bug lasts longer)This bug is extra strange because if you don't restart the app, it is happy to signal that receivers are available during chrome.cast.initialize
.
The source of the bug is here:
ChromecastConnection.java
>
initialize() {
>
startRouteScan
/ScanCallback
/onRouteUpdate
>
if (getContext().getCastState() != CastState.NO_DEVICES_AVAILABLE) {
(line 107)
Never evaluates to true
This is very strange because onRouteUpdate
is called with the actual valid route. Meaning there are indeed routes available. Not sure why getContext().getCastState()
thinks there isn't.
This also only happens on one device that I have tested.
(Samsung tablet, SM-T350, Galaxy Tab A, Android 7.0)
The other device I test on is fine. (LG Phone, LG-M151, LG K4, Android 6.0.1)
I still got the error mentioned on #8 with the latest version:
Unhandled Promise rejection: – "undefined is not an object (evaluating 'this._getMedia().mediaSessionId = 'invalidated'')" – "; Zone:" – "<root>" – "; Task:" – "Promise.then" – "; Value:" (2)
TypeError: undefined is not an object (evaluating 'this._getMedia().mediaSessionId = 'invalidated'') — chrome.cast.js:893
"http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:893:21
http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:731:31
http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:1476:65
callbackFromNative@http://localhost:8100/cordova.js:295:63
http://localhost:8100/plugins/cordova-plugin-ionic-webview/src/www/ios/ios-wkwebview-exec.js:129:35
Originally posted by @JumBay in #6 (comment)
It seems working, but not all the time. I got an error sometimes on the first play and I don't receive any events even if the video plays on the chromecast:
Unhandled Promise rejection: – "undefined is not an object (evaluating 'this._getMedia().mediaSessionId = 'invalidated'')" – "; Zone:" – "<root>" – "; Task:" – "Promise.then" – "; Value:" (2)
TypeError: undefined is not an object (evaluating 'this._getMedia().mediaSessionId = 'invalidated'') — chrome.cast.js:893
"http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:893:21
http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:731:31
http://localhost:8100/plugins/cordova-plugin-chromecast/www/chrome.cast.js:1476:65
callbackFromNative@http://localhost:8100/cordova.js:295:63
http://localhost:8100/plugins/cordova-plugin-ionic-webview/src/www/ios/ios-wkwebview-exec.js:129:35
If I wrap this with a try catch block I don't have the error anymore obviously, but on the restart, the issue is still present
Originally found by @JumBay here
I did find another similar issue.
Cast something, kill the app, reopen it. The session will be retrieved, the media will be retrieved as well with the right playerState but you cannot interact with the media object anymore, play, pause... methods have no effect.
May be a bug on Android as well.
When i create the app in IOS 16 there was no problem, then i update to IOS17 and i have a lot of problems. The pod do not connect and i solve it with this tutorial https://www.youtube.com/watch?v=g0jNo_NIR4g&ab_channel=UvTechSoft but when i try to send information to chromecast nothing works. Do some one have a solution everything works fine on Xcode13. I try to update the POD file but nothing works.
This issue kind of duplicates jellyfin-archive#53, but I thought it better fits to your fork, since I've used your latest master. Also I've some additional information:
loadMedia
-Call seems to work on the remote device, but the app crashes before any of the loadMedia
-callbacks are called.This should probably be dealt with sometime soon hopefully.
We use this in our app and it stopped working a few weeks ago. We made a simple app with just this, and still doesn't work.
Gets to the point where you can select a device and cast, but then just a blue Chromecast icon appears on the device.
Anyone seeing something similar?
Hi! Thank you so much for this plugin! It's been working great so far. More of a question than an issue...
I'm creating a mobile app where I want to show the routes on my own styled UI, and not through the native requestSession popup. Can I obtain a session without the user selecting a route through this requestSession popup.
My app is not casting immediately, but is creating a scheduled task to cast media at certain times of the day. The UI is there to select the route (which I can do without the popup now), and then show a "test" button next to each route for the user to hit it with a quick chirp audio. However sending a test audio requires an active session which seems to only be acquired through the requestSession flow.
Would love any insight on this, and if this is possible in the current set up of this plugin.
Platform: Android
Cordova: 10.0.0
While compiling --debug version, everything works fine.
Only when compiled as --release I get this error at app startup, when initializing Chromecast plugin, of course anything related to Chromacast is not working after the error.
Anyone else experienced this issue?
{
"code":"unknown",
"description":"api_not_initialized null",
"details":{}
}
Hi,
Do you know how to load subtitles?
I've tried this:
var englishSubtitle = new chrome.cast.media.Track(1, chrome.cast.media.TrackType.TEXT);
englishSubtitle.trackContentId = 'https://thepaciellogroup.github.io/AT-browser-tests/video/subtitles-en.vtt';
englishSubtitle.trackContentType = 'text/vtt';
englishSubtitle.subtype = chrome.cast.media.TextTrackType.SUBTITLES;
englishSubtitle.name = 'English Subtitles';
englishSubtitle.language = 'en-US';
englishSubtitle.customData = null;
var videoUrl = 'https://ia801302.us.archive.org/1/items/TheWater_201510/TheWater.mp4';
var mediaInfo = new chrome.cast.media.MediaInfo(videoUrl, 'video/mp4');
mediaInfo.metadata = {
title: 'My Title',
images: [new chrome.cast.Image('https://image.tmdb.org/t/p/w300_and_h450_bestv2/udDclJoHjfjb8Ekgsd4FDteOkCU.jpg')],
tracks: [englishSubtitle]
};
But it kills the app (removing the tracks doesn't kill the app).
I've also tried the mentioned method here with no luck: https://gist.github.com/guerrerocarlos/3aca64069853d8d24a83b481246f23ca
Thanks
Is there any example on how to integrate it with an audio player. I use the cordova media plugin on my app and I need to be able to cast my audio. I install the plugin but I'm a little lost on how to use it. Any help will be appreciate.
I could fix/work around this issue by updating the Cast Framework, here's my fork:
...but work in progress, need to figure out the compile error.
Also, more testing.
// I know that this repo is unmaintained
Hi,
First of all thanks for this great work.
I'm testing your example on an ios simulator. It works, but I've noticed when the sessionListener
is called on a restart, for example, the media
property is always an empty array even if something is playing.
Is there any way to retrieve the current media?
Thx again
sendJavascript is not recommended/deprecated.
We are supposed to use the callbackContext instead.
Here is useful guide to get it started.
And here.
hi, thank you @Lindsay-Needs-Sleep for handling this plugin
I'm just coming to ask if this plugin support subtitle??, trying a lot of tricks to make it work, but still nothing, the subtitle didn't show
my console log for [this.castMedia] :
"tracks":[
{
"trackId"=1,
"type":"VIDEO",
"trackContentType":null,
"trackContentId":"null",
"subtype":'null',
"name":'null',
"language":'null',
"customData":'null'
}
]
code using for
var videoUrl = 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-576p.mp4';
var thesub = 'https://cdn.plyr.io/static/demo/View_From_A_Blue_Moon_Trailer-HD.en.vtt';
const englishSubtitle = new chrome.cast.media.Track(1,chrome.cast.media.TrackType.TEXT);
englishSubtitle.trackContentId =thesub ;
englishSubtitle.trackContentType = 'text/vtt';
englishSubtitle.subtype = chrome.cast.media.TextTrackType.SUBTITLES;
englishSubtitle.name = 'English';
englishSubtitle.language = 'en-US';
englishSubtitle.customData = null;
var tracks = [englishSubtitle];
var mediaInfo = new chrome.cast.media.MediaInfo(videoUrl);
/**/ mediaInfo.tracks = tracks;
mediaInfo.activeTrackIds = [1];
this.isCasting = true;
this.castSession.loadMedia(new chrome.cast.media.LoadRequest(mediaInfo), (media:any)=> {
// You should see the video playing now!
// Got media!
this.castMedia = media;
alert(JSON.stringify(this.castMedia, null, 2));
}, function (err) {
// Failed (check that the video works in your browser)
// alert("Failed : check that the video works in your browser")
alert(JSON.stringify(err, null, 2));
this.isCasting = false;
});
Build failed with this error.
'@objc' method name provides one argument name, but method has 0 parameters in Chromecast.swift
@objc(checkReceiverAvailable:)
@objc(checkReceiverAvailable:)
func checkReceiverAvailable() {
let sessionManager = GCKCastContext.sharedInstance().sessionManager
if self.devicesAvailable.count > 0 || (sessionManager.currentSession != nil) {
self.sendJavascript(jsCommand: "chrome.cast._.receiverAvailable()")
} else {
self.sendJavascript(jsCommand: "chrome.cast._.receiverUnavailable()")
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.