Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*****************************************************************************
- * VLCMediaList.m: VLCKit.framework VLCMediaList implementation
- *****************************************************************************
- * Copyright (C) 2018 David Cordero
- * $Id$
- *
- * Authors: David Cordero <david # corderoramirez.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
- import UIKit
- class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
- var videoView: UIView!
- var tableView:UITableView!
- var stations = [String]()
- var urls = [String]()
- private var mediaPlayer: VLCMediaPlayer!
- override func viewDidLoad() {
- super.viewDidLoad()
- videoView = UIView(frame: view.bounds)
- mediaPlayer = VLCMediaPlayer()
- mediaPlayer.drawable = view
- //mediaPlayer.media = VLCMedia(url: URL(string: "https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4")!)
- //mediaPlayer.play()
- stations = ["big_buck_bunny","Animals","Free","YouTube","Favorites","Paid"]
- urls = ["https://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4", "https://staging.coverr.co/s3/mp4/Fetcher.mp4"]
- setUpTableView()
- }
- func setUpTableView(){
- let tableFrame:CGRect = CGRect(x: 0, y: 120, width: (self.view.frame.width / 3)-50 , height: self.view.frame.height-450)
- tableView = UITableView(frame: tableFrame, style: .grouped)
- view.addSubview(tableView)
- self.tableView.dataSource = self
- self.tableView.delegate = self
- }
- func numberOfSections(in tableView: UITableView) -> Int {
- //1 column
- return 1
- }
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return stations.count
- }
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = UITableViewCell(style: .subtitle, reuseIdentifier: nil)
- cell.textLabel?.text = "\( stations[indexPath.row] )"
- return cell
- }
- func tableView(_ tableView: UITableView, didHighlightRowAt indexPath: IndexPath) {
- //this runs on press
- print (indexPath.item)
- print( stations[indexPath.item] )
- mediaPlayer.media = VLCMedia(url: URL(string: urls[indexPath.item])!)
- mediaPlayer.play()
- mediaPlayer.brightness
- }
- func tableView(_ tableView: UITableView, didUpdateFocusIn context: UITableViewFocusUpdateContext, with coordinator: UIFocusAnimationCoordinator) {
- //runs anytime we move up or down the table view
- //
- if ( context.nextFocusedIndexPath == nil){
- print ("not browsing the table")
- return
- }
- print ( context.nextFocusedIndexPath!.item )
- //use that number to populate something else probably according to the category.
- }
- override func didReceiveMemoryWarning() {
- super.didReceiveMemoryWarning()
- // Dispose of any resources that can be recreated.
- }
- override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
- for press in presses {
- switch press.type {
- case .playPause:
- if mediaPlayer.isPlaying {
- mediaPlayer.pause()
- }
- else {
- mediaPlayer.play()
- }
- default: ()
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement