Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;
using System.Collections;
public class PlayerControl : MonoBehaviour
{
[HideInInspector]
public bool facingRight = true; // For determining which way the player is currently facing.
[HideInInspector]
public bool jump = false; // Condition for whether the player should jump.
#pragma strict
// Objects to drag in
public var motor : MovementMotor;
public var character : Transform;
public var cursorPrefab : GameObject;
public var joystickPrefab : GameObject;
// Settings
public var cameraSmoothing : float = 0.01;
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, strong) UIWindow *window;
@property (nonatomic, strong) UIViewController *rootViewController;
@end
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"MCDJ"
initialProperties:nil
launchOptions:launchOptions];
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
UIViewController *rootViewController = [[UIViewController alloc] init];
rootViewController.view = rootView;
#import <Foundation/Foundation.h>
#import "RCTBridge.h"
#import "RCTEventDispatcher.h"
#import <MediaPlayer/MediaPlayer.h>
@import AVFoundation;
@interface MediaController : NSObject<RCTBridgeModule,MPMediaPickerControllerDelegate, AVAudioPlayerDelegate>
@stan229
stan229 / MediaController.m
Created October 15, 2015 04:46
Showing and Hiding MPMediaPlayerController instance
-(void)showMediaPicker {
if(self.mediaPicker == nil) {
self.mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeAnyAudio];
[self.mediaPicker setDelegate:self];
[self.mediaPicker setAllowsPickingMultipleItems:NO];
[self.mediaPicker setShowsCloudItems:NO];
self.mediaPicker.prompt = @"Select song";
}
@stan229
stan229 / MediaController.m
Created October 15, 2015 04:48
Communicating with React Native app
-(void) mediaPicker:(MPMediaPickerController *)mediaPicker didPickMediaItems:(MPMediaItemCollection *)mediaItemCollection {
MPMediaItem *mediaItem = mediaItemCollection.items[0];
NSURL *assetURL = [mediaItem valueForProperty:MPMediaItemPropertyAssetURL];
[self.bridge.eventDispatcher sendAppEventWithName:@"SongPlaying" body:[mediaItem valueForProperty:MPMediaItemPropertyTitle]];
//...
}
'use strict';
var React = require('react-native');
var MediaController = require('NativeModules').MediaController;
var {
AppRegistry,
StyleSheet,
Text,
TouchableHighlight,
@stan229
stan229 / MediaController.m
Created October 15, 2015 05:00
Full Implementation
#import "MediaController.h"
#import "AppDelegate.h"
@implementation MediaController
RCT_EXPORT_MODULE();
@synthesize bridge = _bridge;
import React, { Component } from 'react';
import {
View,
Text,
TouchableOpacity
} from 'react-native';
class MyComponent extends Component {
componentWillMount() {