Using YouTubeVideoPlayer with Monogame - xamarin.android

I'm currently trying to integrate a video player into my monodroid application. Wondering if there are any helpful solutions to this issue. Unable to load the player into the application (seems that multiple SurfaceViews can't be loaded at the same time). I'm currently trying to hide the monogame window by setting it invisible, and then adding the player to a containing FrameLayout. It seems after getting the player to display correctly, I'm unable to recover the game window, and I'm left with a blank screen (Even after removing all manually loaded textures from the application, I'm still not able to get anything to render! see here).
I'd like to know if anyone's found a successful solution to incorporating the MediaPlayer into monogame?

Not for youtube but, in the monogame samples there is a video player project. It was building and running for me but not showing the video on the emulator, I couldn't test with a real device https://github.com/CartBlanche/MonoGame-Samples/tree/master/VideoPlayer
To run the project you can go to https://github.com/CartBlanche/MonoGame-Samples/tree/master/ and open the MonoGame.Samples.Android.sln

Related

Rox Video Xamarin Forms Ios Not working

I am using Rox video plugin to play videos in Xamarin forms iOS. It plays the video perfectly however if I change device orientation or change to a different screen the video continues to play in the background. I can hear the audio continuing. When returning to the video player view I it loads a new version of the video up.
Can anyone with experience in the Rox Video plugin assist? or offer a free alternative to this plugin?
I searched the issue list of RoxXamarinVideo on github but found nothing about your problem.
I suggest you use FormsNativeVideoPlayer, it seems to have a great support on orientation changes.

Show now playing info on lock screen XAMARIN iOS

I use BASS.Net in my project to play audio files. It works well but now I'd like to show playing information on lock screen. I tried to use MPNowPlayingInfoCenter.DefaultCenter.NowPlaying property to setup info. However it doesn't work as expected - on emulator I do see my info but now playing window doesn't understand that it's playing and shows play button. On iPhone there is no info at all.
Not sure what to do because in mostly all examples use NowPlaying property.
I need some help here. Anyone?

HTML Recording video on iOS

I'm new to HTML coding, and i'm currently trying to build an app in iOS like snapchat, that will take a users camera and record without stopping if the user goes into the main menu or whatever. I'm looking for some HTML5 code that will allow me to have the main interface just be the back camera output, with buttons that i'll have over the front.
A few searches have led me here: http://www.html5rocks.com/en/tutorials/getusermedia/intro/
Which I have tried to make work but iOS does not support it.
I'm basically asking: How do I make an app record video with it starting on screen?
You could write a web app to do this, but not a native app (i.e. from the App Store). For that, you'll need to learn Objective-C or Swift, then take a look at the AVFoundation framework.

Cordova - 'AVAudioSessionDelegateMediaPlayerOnly end interruption' error after pausing and resuming an app

This issue has arose using Cordova to play videos within an iOS application. I had thought to use the pause/resume feature to interact with the HTML5 video. However even when the video has stopped playing and the element has been set to display:none, or faded out etc, this error still appears in the console after the app is resumed - which then renders all video playing useless after it.
MP AVAudioSessionDelegateMediaPlayerOnly end interruption. Interruptor
<________-1874> category <(null)> resumable <0>, _state = 1
I have found issues relating to this, but are answered using C Objective for native app building.. and because I am using Cordova to build they do not apply unfortunately.
Has anyone else playing videos within PhoneGap/Cordova/Chrome Apps come across this and can offer a solution? Or anyone coding Native iOS apps could offer some advice as to why it is happening?
So to fix this (for anyone who may come across this in the future!), i had to resort to a bit of a hacky method.
When the Cordova iOS app is pushed to the background, and resumed, it looks as though any running video tags were unable to continue load and play video - the error above pops up in Xcode console and the video element is black no matter what. (I was fading still images on top of a video tag, then loading a new video using data attributes after a hotspot on the image is pressed). So when the app is paused I had to use JS/jQuery to remove and on resume it re-creates the video element and used the last selected data attributes to pick up the info from where it left off..
Seems to work, and is surprisngly seamless! :)

Mobile Safari: Audio + cache manifest

I'm having a small web app, which plays really short sound bits on the click of several buttons. It explicitly targets mobile Safari on iOS (iPad).
After reading here and elsewhere about the several "shortcomings" of HTML5 audio in this context on mobile Safari and trying a few "hacks" and tricks, I'm stuck with a situation where Safari seems simply (for the lack of a better word) broken:
I can play sound A (it takes a long time for it to start — I'm assuming it's downlading [again]?) on the click of button A. After that, clicking on button B will immediately play the sound A again. Same for button C. In some cases it will play a different sound, sometimes even the right one. But mostly sound A. The format in use was .aiff, is now .m4a .
After writing a few tiny versions myself, I decided to go with the Buzz library to handle the sound loading/playing/etc..
Funnily enough, their demo includes a game, which does pretty much exactly what I need and triggers the same faulty behavior. I even ended up in a situation where any audio player in mobile Safari in any tab would play a certain sound out of the Buzz demo game (!).
I was hoping a cache manifest might help overcome Apples preloading limitations and force the app to play the sound right after hitting the button in offline mode. But after confirming that the whole app had been cached, I can't play/hear any sound in offline mode.
Has anyone managed to get something like this to work somehow? (— Having seen how Apple handles certain things, I' don't expect much response, though… )
Update 1:
The example in this answer causes the same effect: How to synthesize audio using HTML5/Javascript on iPad
Update 2:
Updating iOS (and so Safari) seems to resolve the audio bug. The cache manifest doesn't seem to effect audio files, though. These files are just not available at all.
After removing the cache manifest the app works okay, but adding it to the "home screen" and reloading it prevents the audio from playing as well.
I wish I could tell you there's a magic formula to get all your html5 media to work perfectly, but there isn't. Mobile support for HTML5 audio/video is pretty poor right now; much further behind than its desktop predecesors. To make matters worse, each of the different platforms handle it differently and most of them only support it in semi-recent versions.
However, there are some tricks you can employ to get media files to work correctly in mobile Safari. In order to explain them, you'll need to understand some of its shortcomings.
1) You can't load multiple audio / video files
Its been my experience that the browser will only load one file at a time. If you play one file, go and play another, and then come back and it'll just load that file all over again. And, although I didn't try it myself, I don't believe a cache manifest will help you here.
What I had to do is combine all my audio files into one large audio file. Then, depending on which audio track was requested, I'd move the play position to the appropriate starting position and play that track. Then, I'd use a setInterval to examine the playback every few milliseconds to determine if the current play position hit the end of the track. Once it did, I paused it. Pluis, I gave myself a few seconds (2-3) between each track, just in case the phone's CPU was under a lot of load and checked the feed a little too late.
2) You can't auto-play audio / video files
Apple built into their HTML5 media tag technology the limitation that these tracks would only load and play in response to a user click event. That way, developers couldn't auto-play annoying tracks when you went to their websites.
When I was using audio/video tags, I was trying to build a rich media advertisement. So I hooked my audio/tracks loading to the banner click event, when you click a banner and expand the advertisement.
What I'd suggest you should do is have a small lightbox popup come up, asking the user if they want to turn on/off sound. You can attach your load functions to the click event of that popup box, regardless if the user turns the sound on or off.
Personally, I didn't have much luck using the load() function. I'd run that function to load the audio and then click play and it would just load it again. It could have always been that I just didn't do it right, so feel free to prove me wrong and get that working. What did is I told the track to play, so that way it would start loading, and then I'd use a setInterval to see if the current play time incremented just a few milliseconds. Once I noticed that it started to play the track, I'd immediately pause it.
3) Audio/Video tags are only supported in iOS 4.0 and higher
There's no trick to getting around this. Its just the facts.
Here's a few sites that helped when when I was developing with audio/video tags:
http://www.w3.org/wiki/HTML/Elements/video
http://dev.w3.org/html5/spec-author-view/video.html#media-elements
Good luck!

Resources