flutter_cast_framework_modern/docs/api/index.html
gianlucaparadise 0cbf1d911e Published docs
2022-01-03 14:25:06 +01:00

234 lines
8.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, user-scalable=no">
<meta name="generator" content="made with love by dartdoc 4.1.0">
<meta name="description" content="flutter_cast_framework API docs, for the Dart programming language.">
<title>flutter_cast_framework - Dart API docs</title>
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto+Mono:ital,wght@0,300;0,400;0,500;0,700;1,400&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="static-assets/github.css?v1">
<link rel="stylesheet" href="static-assets/styles.css?v1">
<link rel="icon" href="static-assets/favicon.png?v1">
</head>
<body data-base-href=""
data-using-base-href="false">
<div id="overlay-under-drawer"></div>
<header id="title">
<button id="sidenav-left-toggle" type="button">&nbsp;</button>
<ol class="breadcrumbs gt-separated dark hidden-xs">
<li class="self-crumb">flutter_cast_framework package</li>
</ol>
<div class="self-name">flutter_cast_framework</div>
<form class="search navbar-right" role="search">
<input type="text" id="search-box" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
</form>
</header>
<main>
<div id="dartdoc-main-content" class="main-content">
<section class="desc markdown">
<h1 id="flutter-cast-framework">Flutter Cast Framework</h1>
<h2 id="overview">Overview</h2>
<p>Flutter Cast Framework is a POC of a flutter plugin that lets you use Chromecast API in a flutter app.</p>
<h2 id="exposed-apis">Exposed APIs</h2>
<p>Currently only the following APIs are integrated (both Android and iOS):</p>
<ul>
<li>Cast State</li>
<li>Session state</li>
<li>Send custom message</li>
<li>Listen to received custom messages</li>
<li>Load RemoteMediaRequestData</li>
<li>Play, Pause, Stop media</li>
<li>Expanded controls</li>
<li>Cast Button</li>
<li>Chromecast connection</li>
</ul>
<h2 id="setup">Setup</h2>
<h4 id="add-dependency">Add Dependency</h4>
<p>Clone this repo and add the following piece of code to your app's pubspec</p>
<pre class="language-yaml"><code class="language-yaml">dependencies:
flutter_cast_framework:
path: ../flutter_cast_framework/ # the path depends on where you cloned this repo
</code></pre>
<h3 id="android-setup">Android Setup</h3>
<h4 id="1-create-castoptionsprovider">1. Create <code>CastOptionsProvider</code></h4>
<p>Add the following class to your Android project:</p>
<pre class="language-kotlin"><code class="language-kotlin">import android.content.Context
import com.google.android.gms.cast.framework.CastOptions
import com.google.android.gms.cast.framework.OptionsProvider
import com.google.android.gms.cast.framework.SessionProvider
class CastOptionsProvider : OptionsProvider {
override fun getCastOptions(context: Context): CastOptions {
return CastOptions.Builder()
.setReceiverApplicationId("4F8B3483") // Your receiver Application ID
.build()
}
override fun getAdditionalSessionProviders(context: Context): List&lt;SessionProvider&gt;? {
return null
}
}
</code></pre>
<h4 id="2-load-castoptionsprovider">2. Load <code>CastOptionsProvider</code></h4>
<p>Add the following entry in the <code>AndroidManifest.xml</code> file under the <code>&lt;application&gt;</code> tag to reference the <code>CastOptionsProvider</code> class:</p>
<pre class="language-xml"><code class="language-xml">&lt;application&gt;
&lt;meta-data
android:name="com.google.android.gms.cast.framework.OPTIONS_PROVIDER_CLASS_NAME"
android:value="com.gianlucaparadise.flutter_cast_framework_example.CastOptionsProvider" /&gt;
&lt;/application&gt;
</code></pre>
<h4 id="3-theme">3. Theme</h4>
<p>Make sure that your application and your activity are using an <code>AppCompat</code> theme (as stated <a href="https://developers.google.com/cast/docs/android_sender/integrate#androidtheme">here</a>).</p>
<h3 id="ios-setup">iOS Setup</h3>
<h4 id="1-minimum-ios-version">1. Minimum iOS version</h4>
<p>Make sure you minimum iOS version is 10.0.
Select <em>Runner</em> from left pane &gt; <em>General</em> tab &gt; <em>Deployment Info</em> &gt; <em>Target</em>: set 10.0 or higher</p>
<h4 id="2-install-ios-dependencies">2. Install iOS dependencies</h4>
<p>When Xcode is closed, open a terminal at the root folder of your project and run:</p>
<pre class="language-bash"><code class="language-bash">cd ios &amp;&amp; pod install
</code></pre>
<h4 id="3-open-project-in-xcode">3. Open project in Xcode</h4>
<p>To open your flutter project with Xcode, from root folder run <code>open ios/Runner.xcworkspace</code></p>
<h4 id="4-chromecast-sdk-setup">4. Chromecast SDK setup</h4>
<p>Add the following lines to your <code>AppDelegate.swift</code>:</p>
<pre class="language-diff"><code class="language-diff"> import UIKit
import Flutter
+import GoogleCast
@UIApplicationMain
-@objc class AppDelegate: FlutterAppDelegate {
+@objc class AppDelegate: FlutterAppDelegate, GCKLoggerDelegate {
+ let kReceiverAppID = "4F8B3483" // Your receiver Application ID
+ let kDebugLoggingEnabled = true
+
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
) -&gt; Bool {
+ let criteria = GCKDiscoveryCriteria(applicationID: kReceiverAppID)
+ let options = GCKCastOptions(discoveryCriteria: criteria)
+ GCKCastContext.setSharedInstanceWith(options)
+
+ // Enable logger.
+ GCKLogger.sharedInstance().delegate = self
+
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
+
+ // MARK: - GCKLoggerDelegate
+
+ func logMessage(_ message: String,
+ at level: GCKLoggerLevel,
+ fromFunction function: String,
+ location: String) {
+ if (kDebugLoggingEnabled) {
+ print(function + " - " + message)
+ }
+ }
}
</code></pre>
<h2 id="tech-notes">Tech notes</h2>
<p>I used this project to test the capabilities of the following technologies:</p>
<ul>
<li>Chromecast API (Sender - Android SDK)</li>
<li>Flutter</li>
<li>Flutter custom platform-specific code</li>
</ul>
<h2 id="roadmap">Roadmap</h2>
<ul>
<li>CC in Expanded Controls (iOS)</li>
<li>Handle Ad Break (ad skip, ad UI, ad countdown)</li>
<li>Handle progress seek</li>
<li>Handle queue</li>
<li>Handle mini-player</li>
</ul>
</section>
<section class="summary">
<h2>Libraries</h2>
<dl>
<dt id="cast">
<span class="name"><a href="cast/cast-library.html">cast</a></span>
</dt>
<dd>
</dd>
<dt id="widgets">
<span class="name"><a href="widgets/widgets-library.html">widgets</a></span>
</dt>
<dd>
</dd>
</dl>
</section>
</div> <!-- /.main-content -->
<div id="dartdoc-sidebar-left" class="sidebar sidebar-offcanvas-left">
<header id="header-search-sidebar" class="hidden-l">
<form class="search-sidebar" role="search">
<input type="text" id="search-sidebar" autocomplete="off" disabled class="form-control typeahead" placeholder="Loading search...">
</form>
</header>
<ol class="breadcrumbs gt-separated dark hidden-l" id="sidebar-nav">
<li class="self-crumb">flutter_cast_framework package</li>
</ol>
<h5 class="hidden-xs"><span class="package-name">flutter_cast_framework</span> <span class="package-kind">package</span></h5>
<ol>
<li class="section-title">Libraries</li>
<li><a href="cast/cast-library.html">cast</a></li>
<li><a href="widgets/widgets-library.html">widgets</a></li>
</ol>
</div>
<div id="dartdoc-sidebar-right" class="sidebar sidebar-offcanvas-right">
</div>
</main>
<footer>
<span class="no-break">
flutter_cast_framework
0.0.1
</span>
</footer>
<script src="static-assets/highlight.pack.js?v1"></script>
<script src="static-assets/script.js?v1"></script>
</body>
</html>