Shaka Player Embedded
Welcome to Shaka Player Embedded

Prerequisites

Building Shaka Player Embedded requires the following:

To summarize, you should install homebrew and pip, if you don't already have them, and then run:

sudo xcode-select --install -s /Applications/Xcode.app/Contents/Developer
brew install autoconf automake pkg-config cmake libtool
pip install --user enum34

Building the framework

Once you have installed all of the prerequisites, it's time to build Shaka Player Embedded. If you don't already have it, you can fetch the code with:

git clone https://github.com/google/shaka-player-embedded.git
cd shaka-player-embedded

Then, you need to configure a build. Device builds and simulator builds require different configuration values. To configure for the iPhone simulator, you can do the following:

mkdir myBuildSim
cd myBuildSim
../configure --ios

To configure for deployment onto an actual iPhone, you just change the CPU you are building for.

mkdir myBuild
cd myBuild
../configure --ios --cpu arm64

This will result in a debug configuration; if you want a release build, add the --release argument.

Once you have made a configuration, you can run make to build the most recent configuration. Or, if you want to build a specific configuration, you can run the build script on that configuration.

../build.py

Using the framework

Now that you have a complete framework, it's time to put it to use.

Make a new single-view project with XCode.

Inside the folder you put Shaka Player Embedded, navigate to the folder that you made for your build, and find the files named ShakaPlayerEmbedded.framework and ShakaPlayerEmbedded.FFmpeg.framework. Drag that file into your project. Be sure to check copy items if needed, and uncheck any Add to targets boxes.

tutorial-add-file.png
Adding the framework to the project

Then, go to the project settings, and navigate to General. Go to Embedded Binaries, and add ShakaPlayerEmbedded.framework and ShakaPlayerEmbedded.FFmpeg.framework as an embedded binaries.

tutorial-embed-binaries-1.png
Embedding the framework, part 1
tutorial-embed-binaries-2.png
Embedding the framework, part 2

Next, navigate to Build Settings. Search for the System Framework Search Paths setting. Be sure to have All checked, rather than Basic or Customized. Add '$(PROJECT_DIR)' to the setting. This is required to properly link the framework.

tutorial-search-paths.png
Setting search paths

Then, search for Enable Bitcode, and set it to No. At the moment, we do not build the framework with Bitcode.

tutorial-disable-bitcode.png
Disabling Bitcode

If you are using Swift...

Go to ViewController.swift, and replace its contents with the following code:

import UIKit
import ShakaPlayerEmbedded
class ViewController: UIViewController, ShakaPlayerClient {
func onPlayer(_ player: ShakaPlayer, error: ShakaPlayerError) {
print("Got Shaka Player Error: \(error.message)")
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Make a Shaka Player with its corresponding view.
guard let player = try? ShakaPlayer() else {
print("Error creating player")
return
}
player.client = self
let playerView = ShakaPlayerView(player: player)
playerView.frame = self.view.bounds
self.view.addSubview(playerView)
// Load and play an asset.
player.load("https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd") {
if let error = $0 {
print("Error loading manifest: \(error.message)")
} else {
player.play()
}
}
}
}

If you are using Objective-C...

Go to ViewController.m, and replace its contents with the following code:

#import "ViewController.h"
#import <ShakaPlayerEmbedded/ShakaPlayerEmbedded.h>
//
Doxygen_Skip
@implementation ViewController
- (void)onPlayer:(ShakaPlayer *)player error:(ShakaPlayerError *)error {
NSLog(@"Got Shaka Player Error: %@", [error message]);
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
// Make a Shaka Player with is corresponding view.
ShakaPlayer *player = [[ShakaPlayer alloc] initWithError:nil];
player.client = self;
ShakaPlayerView *playerView = [[ShakaPlayerView alloc] initWithPlayer:player];
playerView.frame = self.view.bounds;
[self.view addSubview:playerView];
// Load and play an asset.
[player load:@"https://storage.googleapis.com/shaka-demo-assets/angel-one/dash.mpd"
withBlock:^(ShakaPlayerError *error) {
if (error)
NSLog(@"Error loading manifest: %@", [error message]);
else
[player play];
}];
}
@end

That's all you need to do to play an asset!