RemoteMediaClient created demo receiver
This commit is contained in:
parent
cc5e5f9696
commit
2125ebf893
5 changed files with 66 additions and 3 deletions
3
Makefile
3
Makefile
|
|
@ -6,3 +6,6 @@ pigeon: # Generates the typesafe bridge between host and flutter
|
|||
--objc_source_out ios/Classes/PlatformBridgeApis.m \
|
||||
--java_out ./android/src/main/java/com/gianlucaparadise/flutter_cast_framework/PlatformBridgeApis.java \
|
||||
--java_package "com.gianlucaparadise.flutter_cast_framework"
|
||||
|
||||
deploy-receiver:
|
||||
surge receiver
|
||||
|
|
@ -9,7 +9,7 @@ import com.google.android.gms.cast.framework.SessionProvider
|
|||
class CastOptionsProvider : OptionsProvider {
|
||||
override fun getCastOptions(context: Context): CastOptions {
|
||||
return CastOptions.Builder()
|
||||
.setReceiverApplicationId("4F8B3483")
|
||||
.setReceiverApplicationId("D6760CCD")
|
||||
.build()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import GoogleCast
|
|||
|
||||
@UIApplicationMain
|
||||
@objc class AppDelegate: FlutterAppDelegate, GCKLoggerDelegate {
|
||||
let kReceiverAppID = "4F8B3483"
|
||||
let kReceiverAppID = "D6760CCD"
|
||||
let kDebugLoggingEnabled = true
|
||||
|
||||
override func application(
|
||||
|
|
|
|||
1
receiver/CNAME
Normal file
1
receiver/CNAME
Normal file
|
|
@ -0,0 +1 @@
|
|||
flutter-cast-framework-demo.surge.sh
|
||||
59
receiver/index.html
Normal file
59
receiver/index.html
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/toastify-js/src/toastify.min.css">
|
||||
<script type="text/javascript" src="//www.gstatic.com/cast/sdk/libs/caf_receiver/v3/cast_receiver_framework.js">
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<cast-media-player></cast-media-player>
|
||||
|
||||
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
|
||||
<script>
|
||||
const namespace = "urn:x-cast:flutter-cast-framework-demo";
|
||||
const context = cast.framework.CastReceiverContext.getInstance();
|
||||
|
||||
const showMessage = (text) => {
|
||||
if (!text) return;
|
||||
|
||||
Toastify({
|
||||
text: text,
|
||||
duration: 3000,
|
||||
gravity: "bottom",
|
||||
position: "right", // `left`, `center` or `right`
|
||||
stopOnFocus: true, // Prevents dismissing of toast on hover
|
||||
style: {
|
||||
background: "#4496EC",
|
||||
},
|
||||
}).showToast();
|
||||
}
|
||||
|
||||
const sendMessage = (senderId) => {
|
||||
senderId = !senderId ? undefined : senderId; // When senderId is undefined, this broadcasts to all connected devices
|
||||
const message = `Received text from ${senderId} at ${new Date().toISOString()}`
|
||||
|
||||
console.log('Sending CustomMessage: ');
|
||||
console.log(message);
|
||||
|
||||
context.sendCustomMessage(namespace, senderId, message);
|
||||
}
|
||||
|
||||
const onCustomMessage = (event) => {
|
||||
console.log('Received CustomMessage: ');
|
||||
console.log(event);
|
||||
|
||||
const text = event?.data?.text;
|
||||
showMessage(text);
|
||||
|
||||
const senderId = event?.senderId;
|
||||
sendMessage(senderId);
|
||||
}
|
||||
|
||||
context.addCustomMessageListener(namespace, onCustomMessage)
|
||||
|
||||
context.start();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
Reference in a new issue