I'm making a video stream app using VLC player.
I installed mobileVLCKit-unstable and successfully streamed video but it stops within 1 minute.
I found out that the VLC library's 'hardware decoding' option is 'on'. But I can't find how to do it.
This is what I tried:
myplayer = VLCMediaPlayer
myplayer.media.addOptions(["network-caching":1000]) // this is hint
myplayer.media.addOptions(["hardware-decoding":false]) // i tried, but not worked
myplayer.media.addOptions(["avcodec":false]) // i tried, but not worked
I'm using Swift 4, Xcode 10.
You shouldn’t use the unstable pod of MobileVLCKit anymore. This is no longer needed and will give you a very old and unstable version of the library as we no longer update this pod. Just use the normal MobileVLCKit pod and try again.
Disabling hardware decoding will NOT solve your problem. Please post a debug log of the stable library so we can take a more detailed look.
I solved this problem.
I added an option
let option : [String] = ["--codec=avcodec"]
let player : VLCMediaPlayer = VLCMediaPlayer(options : options)
Then I confirmed the playing time of over 30 minutes.
I am facing a strange issue, after I started running my app on iOS11 devices.
I do NOT have a 'rejection' from Apple but it simply stopped working on devices/simulators using iOS11.
For the call action to a number, I used the below code which worked well (and still works) on iOS10 simulators and devices.
let myPhoneNumber = "123456789"
if let url = URL(string: "telprompt://\(myPhoneNumber)"), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.openURL(url)
}
The same code doesn't work on iOS 11 anymore. I have my project migrated to Swift 4.0.2 as well.
Did I miss something specific?
PS: I have this in my info.plist already added under the LSApplicationQueriesSchemes
I load on UIWebView a HTML game from local files.
iOS 10.2 / XCode 8 / Swift 3
override func viewDidLoad() {
super.viewDidLoad()
if let path = Bundle.main.path(forResource: "index", ofType: "html", inDirectory: "game") {
webView.loadRequest(URLRequest(url : URL(fileURLWithPath: path)))
}
}
Everything seems fine, but I cant hear any sound on game.
I open the same files (game) from localhost server via Mobile's Safari browser and sound seems OK. So i'm sure that html/javascript files & connection is OK and issue has to do with iOS.
Added "Required background modes" -- > "App plays audio or streams audio/video" in info.plist but nothing changed. No sound on device.
You should run this line before webview.loadRequest(...)
AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, error: nil)
I answer my own question just in case someone has the same problem. I found a solution, by running my app on a localserver. I used GCDWebServer and everything went OK.
Not sure why happened this sound issue and solved by that way, but i suppose it's a matter of javascript "security" on iOS or something similar.
This post game me the answer.
I am running a watchkit app which uses app groups and I can't seem to get it running at all. Anytime I try and run the app I get an alert which says "SPErrorGizmoInstallNeverFinishedErrorMessage".
The code in my glance controller is relatively short.
let sharedGroupName = NSBundle.mainBundle().objectForInfoDictionaryKey("Shared Group") as! String
var sharedDefaults:NSUserDefaults!
override func willActivate() {
super.willActivate()
sharedDefaults = NSUserDefaults(suiteName: sharedGroupName)
var timer = NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: Selector("update"), userInfo: nil, repeats: true)
}
func update() {
println(sharedDefaults?.valueForKey("timeMessage") as! String)
}
The code in my ViewController.swift is short as well also just setting this share defaults object:
let sharedGroupName = NSBundle.mainBundle().objectForInfoDictionaryKey("Shared Group") as! String
var sharedDefaults:NSUserDefaults!
sharedDefaults?.setObject(timeMessage.text, forKey: "timeMessage")
sharedDefaults?.synchronize()
This error is preventing me from running any watchkit app at all. Not the main app or the glance or notification.
I have one app group which is listed in the info.plist.
I have a custom build setting to the app groups name.
Any help would be greatly appreciated.
I fixed this issue by going to the simulator's watch companion app, unchecking the installation for the watch app, then turning it back on. Nothing else worked.
The only thing that worked for me was to Reset Content and Settings in the simulator. Toggling the watch app off and on in the Apple Watch settings app didn't do it for me.
From reading other Apple Developer forum messages, SPErrorGizmoInstallNeverFinishedErrorMessage seems to occur when the Watch App info.plist has an invalid setting.
I was trying different versions of WKCompanionAppBundleIdentifier and that was my error. When I deleted the copied line, that worked again.
This message started appearing when I added custom keys in the info.plist file.
After much trial and error I was able to fix this by unplugging my external display from my computer. Whether this was the real issue I don't know. All I know is that when I had the external monitor plugged in I got this error and when I unplugged it the error went away. I tested it several times.
For me, it was "Targeted Device Family" settings
For parent app, you could keep it iPhone/iPad (or iPhone, up to you);
For watchkitextension, set it to iPhone;
For watchkitapp, if you want to run in the simulator, set it to iPhone. For actually device, the value seems to be 4 (which you cannot set directly from Xcode yet as of 20150416)
I did nothing but restart Simulator & Clean-build app, then it worked again. :)
If you want to use the group to share the data with IOS app and your apple watch kit using the NSUserdefault, you can follow these steps:
1. Add the group app id in capabilities part of IOS targets app and target watch kit
2. when you want to save the data to NSUSerDefault:
var groupData = NSUserDefaults(suiteName: "group.demoShareData")
// note that suiteName is group app id
// var str = "demotest"
groupData?.setObject(newYearLabel.text, forKey: "timeRemaining")
groupData?.synchronize()
3. when you want to take the data from NSuserDefault:
var groupData = NSUserDefaults(suiteName: "group.demoShareData")
groupData?.synchronize()
if groupData?.objectForKey("timeRemaining") != nil {
var str = groupData?.objectForKey("timeRemaining") as String
println("str \(str)")
self.myLabel.setText(str)
} else {
println("error")
}
Hope this help :)
I found a solution in Xcode 8.3. Make sure that the build setting "Targeted Device Family" is set to iPhone in the WatchKit extension.
I Deleted the App from the simulator, and reinstalled. Seemed to work.
I tried a couple of the other option.
CMD SHIFT K - clean
CMD RUN - run
the error dissapears!
I'm trying to get my app to play a video that has been downloaded to the Documents Directory.
My code works when tested on the iOS 7.1 simulator but not on iOS 8.0 devices or the iOS 8.0 simulator. There isn't any error, AVPlayer does not play the video and shows a Black View.
I also checked the Document's folder of my device with XCode's Organizer and the file appears to be successfully downloaded.
Here is a simplified version of my code.
// file_path is a string that stores the path to the video file a println of it shows
// "/var/mobile/Containers/Data/Application/83C7837C-59B5-4767-A579-7CE758A93C6F/Documents/og4gr.mp4"
var path:NSURL = NSURL.fileURLWithPath(file_path, isDirectory: false);
_player = AVPlayer(URL: path);
Has anyone else encountered this? Thank you for your time!
So the problem was that the Application Documents Folder Path changes every time you launch the app and I was storing the absolute path of the video file.
According to this article here:
http://pinkstone.co.uk/where-is-the-documents-directory-for-the-ios-8-simulator/, this is how it is now in iOS 8, which is why while my method worked in iOS7 it was failing on iOS8 devices and Simulators. Thank you #RoboticCat for pointing me in the right direction!