Video is not playing repeating iOS. Show this log - ios

When I load the Video url in MPMovieplayercontroller in Similator
the log is printing like this what can I do now.
_itemFailedToPlayToEnd: {
kind = 1;
new = 2;
old = 0;
}
So, that the Video is not Viewing in my player
help me..

There could be some problems with your url...
Your url could have spaces. Fill the spaces - stringByAddingPercentEscapesUsingEncoding.
Try changing the source type of the player this might help.
movieplayer. movieSourceType = // source type.
Try running app on a device also sometimes might be the problem due to simulator.
First try on real device if it doesnot work try the above 2 suggestions.

Just a word of warning since I battled this problem for 2 hours and it turned out to be something really simple and quite surprising.
MPMoviePlayerViewController in iOS7 cannot play mov files. In iOS8, however, it works fine.

Related

Unity/Videoplayer - Game sometimes crash if I load next video

I use Video Player which attached 3D game object. This game object contain "Mesh Renderer" component too. Video Player Renderer-> this game object.
I try many method, but always crash game.
I try use in Update: Videoplayer().isplaying if false, then I load from Resources next video and play, but not working. (Unity Editor working fine, but in iPhone sometimes crash game.)
Then I try other method..
But sometimes crash too..
Okey, I think maybe loading and start playing too fast, maybe this cause the crash.
Then I try use Ienumerator waitforsecond every step, for debugging I set it 5 seconds.
I try first set video player.clip = null, maybe this is the problem.. But not..
Now the code:
void Start()
{
index = 0;
videoPlayer = gameObject.GetComponent<VideoPlayer>();
videoPlayer.loopPointReached += CheckOver;
}
IEnumerator Waitforseconds()
{
Debug.Log("Waitforseconds start");
videoPlayer.clip = null;
Debug.Log("Videoplayer clip null);
yield return new WaitForSeconds(5);
videoPlayer.clip = theVideo;
Debug.Log("Videoplayer set the video");
yield return new WaitForSeconds(5);
Debug.Log("Next play video player");
videoPlayer.Play();
Debug.Log("Play video player");
isPlaying = true;
}
void CheckOver(UnityEngine.Video.VideoPlayer vp)
{
Debug.Log("Checkover");
index += 1;
if (index >= videos.Length)
{
index = 0;
}
theVideo = videos[index];
Debug.Log("Set the video");
StartCoroutine(Waitforseconds());
}
The videos size 5-10 MB and 10-60 seconds.
The result: Unity Editor working good, I build to iOS and sometimes crash the game if I play next video (iPhone 12 Pro Max, supposedly the fastest smartphone chip, so if that doesn't work, there's a big problem..)
Debug:
I get last Debug.log before the game crash:
"Videoplayer clip null"
So I think the game crash here: videoPlayer.clip = theVideo;
But only iOS! Unity editor working good.
Xcode error:
I try find solution in google, but I can't find..
Maybe memory error? should I somehow delete the previous video from memory?
Or how can I solve this problem? Please help me.
Thank you very much!
EDIT: I see the problem is Audio. (Audio Output mode: Audio Source, this component attached to same gameobject. So same game object contain audio source and video player.) If I set Audio Output mode to "none", then game not crash, workin good. So the problem when "PrepareAudioTap". How can I solve this problem?
Solved!
I change Video Player component "Audio Output mode": Audio Source to Direct.
Then not crash game.
But I would like to use Audio Source, because I need 3D Sound. (not important, I'm glad it works, but if you have idea how to work with 3D sound, I would be glad.)
Thanks!

Sound Effect Won't Play (XCode/Swift)

So I am following through an old tutorial and I think with the changes in xcode and swift this code is now no longer usable, but i am not sure. Would love some help.
Declaring constant for the audio effect
let cannonSound = SKAction.playSoundFileNamed("cannon.wav", waitForCompletion: false)
Calling the audio effect within my funtion
let hotdogSequence = SKAction.sequence([cannonSound, moveHotdog, deleteHotdog])
hotdog.run(hotdogSequence)
For more info I am using SpriteKit in Xcode and this code is contained within GameScene.swift file.
Update:
The error I receive is
2017-03-30 00:52:43.631 Ballpark Weiner[95999:1983181] SKAction: Error loading sound resource: "cannon.wav"
The game doesn't crash just no sound plays
This message usually means that the file cannot be found in your project or might be corrupt.
You should check that the file is actually copied into your project and is spelled correctly. Its case sensitive so if the actual file is called "Cannon.wav" it will not work.
Hope this helps

AVPlayer does not play Video, play Button with Line through

Im new to swift but i like it more than obj-c as it looks a bit like java does to me from syntax wise compared to obj-c.
My problem is now that most of the source code samples are for obj-c so theyre unreadable for me =)
Anyway i managed to run a few code snippets like this(im not at my mac but they were similar):
let steamingURL:NSURL = NSURL(string: "http://....")!
let player = AVPlayer(URL: steamingURL)
player.allowsExternalPlayback = false
PlayWorkoutViewController.playerController = AVPlayerViewController()
PlayWorkoutViewController.playerController.player = player
self.addChildViewController(PlayWorkoutViewController.playerController)
self.view.addSubview(PlayWorkoutViewController.playerController.view)
PlayWorkoutViewController.playerController.view.frame = videoContainerView.frame
PlayWorkoutViewController.playerController.showsPlaybackControls = false
player.play()
resulting in a Play Button with a line trough it, it doesnt play the Stream.
The stream source is a mpg1/2 stream according to VLCPlayer and its coming from a Linux based satellite receiver.
Another thing i tried was to change that "string:" part to "fileURLWithPath:" at the NSURL variable but that didnt work either.
Is there a way to Buffer the stream or is this just a codec issue, what workaround options do i have?
Im hesitating since three days, i hope its not a duplicate question, thanks.
EDIT: content of the stream.m3u file:
EXTM3U
EXTVLCOPT--http-reconnect=true 192.168.178.20:8001/1:0:1:445D:453:1:C00000:0:0:0:
Security setting might be the problem. Go to info.plist and Add "App Transport Security Settings". Under that add "Allow Arbitrary Loads" and set it to YES. I hope this fixes the problem.

Play default iOS system sound with Monotouch

I want to play the keyboard 'click' sound when pressing buttons in my app.
How do I access this sound clip with Monotouch? I don't want to pass my own sound using AudioToolbox SystemSound.FromFile(). So far all my searches have led to this solution or Objective-C code using 'AudioServicesCreateSystemSoundID' which I'm having trouble translating to C#.
With iOS 7.0 and higher, Stephane Delcroix answer seems not to work anymore...
But you can easily find the path to all the sounds in this nice project:
https://github.com/TUNER88/iOSSystemSoundsLibrary
Here is the code I used und iOS 7 (take care, it might not work with the simulator!)
private const string NotificationSoundPath = #"/System/Library/Audio/UISounds/New/Fanfare.caf";
public static void TriggerSoundAndViber()
{
SystemSound notificationSound = SystemSound.FromFile(NotificationSoundPath);
notificationSound.AddSystemSoundCompletion(SystemSound.Vibrate.PlaySystemSound);
notificationSound.PlaySystemSound();
}
Also the using() construct in the answer above caused trouble in my case... it seems like it released the sound too early, I only can hear it (and even then not complete with viber) with a breakpoint on PlaySystemSound().
Well, that's not a 1:1 port from the code in Playing system sound without importing your own, but this should do the work:
var path = NSBundle.FromIdentifier ("com.Apple.UIKit").PathForResource ("Tock", "aiff");
using (var systemSound = new SystemSound (NSUrl.FromFilename (path))) {
systemSound.PlaySystemSound ();
}
SystemSound is defined in MonoTouch.AudioToolbox. Make sure to also look at MonoTouch Play System Sound and MonoTouch: Playing sound

unsupported video format handling

I am using MPMoviePlayerController to play videos. I want to show an alert to user when the given video does not have a supported format. But I am not getting any error from SDK about it.
When I try to run any unsupported video , it leaves me with MPMovieFinishReasonPlaybackEnded and the following error in the console.
_itemFailedToPlayToEnd: {
kind = 1;
new = 2;
old = 0;
}
Does anyone know about how to handle it?
Have you tried examining the errorLog property of MPMoviePlayerController?
I got the solution for this.
[[[notification userInfo]valueForKey:#"error"] localizedDescription];
This works for me and gives "can not open" for the unsupported formats. Hope it helps others looking for similar problems.

Resources