This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function go() { | |
| var userId = prompt('Username?', 'Guest'); | |
| // Consider adding '/<unique id>' if you have multiple games. | |
| var gameRef = new Firebase(GAME_LOCATION); | |
| assignPlayerNumberAndPlayGame(userId, gameRef); | |
| }; | |
| // The maximum number of players. If there are already | |
| // NUM_PLAYERS assigned, users won't be able to join the game. | |
| var NUM_PLAYERS = 4; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| self.onCollectionReady.subscribe(with: self) { (isReady) in | |
| print("Are assets ready: \(isReady)") | |
| // init player queue | |
| self.playerQueue = AVQueuePlayer(items: self.AVItemPool) | |
| self.playerQueue?.usesExternalPlaybackWhileExternalScreenIsActive = true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // listening for current item change | |
| self.audioQueueObserver = self.playerQueue?.observe(\.currentItem, options: [.new]) { | |
| [weak self] (player, _) in | |
| print("media item changed...") | |
| } | |
| // listening for current item status change | |
| self.audioQueueStatusObserver = self.playerQueue?.currentItem?.observe(\.status, options: [.new, .old], changeHandler: { | |
| (playerItem, change) in | |
| if playerItem.status == .readyToPlay { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var audioQueueObserver: NSKeyValueObservation? | |
| var audioQueueStatusObserver: NSKeyValueObservation? | |
| var audioQueueBufferEmptyObserver: NSKeyValueObservation? | |
| var audioQueueBufferAlmostThereObserver: NSKeyValueObservation? | |
| var audioQueueBufferFullObserver: NSKeyValueObservation? | |
| var audioQueueStallObserver: NSKeyValueObservation? | |
| var audioQueueWaitingObserver: NSKeyValueObservation? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| self.onCollectionReady.subscribe(with: self) { | |
| (isReady) in | |
| print("Are assets ready: \(isReady)") | |
| // init player queue | |
| self.playerQueue = AVQueuePlayer(items: self.AVItemPool) | |
| self.playerQueue?.usesExternalPlaybackWhileExternalScreenIsActive = true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var AVItemPool:Array<AVPlayerItem> = [] { | |
| didSet { | |
| if self.AVItemPool.count == trackArr.count { | |
| self.onCollectionReady.fire(true) | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| import AVFoundation | |
| import UIKit | |
| class AudioPlayer: NSObject { | |
| var audioItem:AVPlayerItem! | |
| private var playerQueue : AVQueuePlayer? | |
| // dispatch queue | |
| let assetQueue = DispatchQueue(label: "randomQueue", qos: .utility) | |
| let group = DispatchGroup() | |
| var asset: AVURLAsset? { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import AVFoundation | |
| let fileURL = NSURL(string: "https://freemusicarchive.org/file/music/ccCommunity/Rotten_Bliss/The_Nightwatchman_Sings/Rotten_Bliss_-_08_-_Timer_Erase.mp3") | |
| let avAsset = AVAsset(url: fileURL! as URL) | |
| let assetKeys = ["playable"] | |
| var playerItem = AVPlayerItem(asset: avAsset, automaticallyLoadedAssetKeys: assetKeys) | |
| var playerQueue = AVQueuePlayer(items: [playerItem]) | |
| playerQueue.play() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // AudioPlayer.swift | |
| // | |
| // Created by MDobekidis | |
| // | |
| import Foundation | |
| import AVFoundation | |
| import UIKit | |
| import Signals |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var number = message.match(/\|.*?\|/g); | |
| var newNumber = String(number).replace(/\|/g, ""); | |
| var finalText = message.replace(number, newNumber); |