microsoft / WinObjC

Objective-C for Windows
MIT License
6.24k stars 808 forks source link

Media Capture and Playback Under Development? What does this mean for Core Audio? #47

Open DancinDirk opened 9 years ago

DancinDirk commented 9 years ago

I was looking through the libraries and Core Audio is basically empty and the notes say Media Capture and Playback are still under development. Does this mean I'm going to have to wait for a bit before I begin work on making my App for Windows if CoreAudio is a major piece of it?

s5msft commented 9 years ago

@DancinDirk Maybe. If you want to directly reuse your iOS code for media capture/playback then you may have to hold off for a bit. Alternatively, if you're willing to #ifdef your way around a few things, then you can directly use relevant Windows APIs as appropriate.

The WOCCatalog sample shows you how to do some of this (admittedly not for CoreAudio though, just for video playback).

DancinDirk commented 9 years ago

Yeah, we spent a lot of time getting audio playback just right using core audio so I'd like to reuse as much of that as possible, unless there's a functionally equal windows version of coreAudio that could be easily substituted in.

On Sat, Aug 8, 2015 at 6:08 PM, Salmaan Ahmed notifications@github.com wrote:

@DancinDirk https://github.com/DancinDirk Maybe. If you want to directly reuse your iOS code for media capture/playback then you may have to hold off for a bit. Alternatively, if you're willing to #ifdef your way around a few things, then you can directly use relevant Windows APIs as appropriate.

The WOCCatalog sample shows you how to do some of this (admittedly not for CoreAudio though, just for video playback).

— Reply to this email directly or view it on GitHub https://github.com/Microsoft/WinObjC/issues/47#issuecomment-129057683.

colincornaby commented 9 years ago

I'd love to see CoreAudio. In since CoreAudio is a C API, it would also be awesome to be able to share code with non Obj-C Windows apps. It would be nice to be able to share CoreAudio code without bringing in all the Obj-C support.

Alx06 commented 9 years ago

Is there any simple way to play an mp3 file?

s5msft commented 9 years ago

@hervevi For simple media playback, you can use Xaml's MediaElement and embed it right in you app.

See the following bit from one of the samples: https://github.com/Microsoft/WinObjC/blob/master/samples/WOCCatalog/WOCCatalog/XamlViewController.m#L117

If you replace the given URL with something pointing to an mp3 file then you should get audio playback.

Alx06 commented 9 years ago

@s5msft Thanks for this help, could you tell me how to read a mp3 embedded in the project? I tried to set the Uri to the name of my file, with or without the path, the program crashes (assertion failed). It does not find the file.

Alx06 commented 9 years ago

I found a way to load the mp3 file that does not crash the program, but I can't hear anything :( Here is my source code, called each time a mp3 should be played:

WXCMediaElement *mediaElement = [WXCMediaElement create]; mediaElement.autoPlay = YES; mediaElement.source = [WFUri createUri: @"ms-appx:///mysound.mp3"]; [mediaElement play];

No crash, but no sound too :(

s5msft commented 9 years ago

It's either that the Volume property isn't set/correct or that you need to add the MediaElement to the current View (WOCCatalog shows you how to do that). You should be able to set the width/height to 0 if you want no UI at all.

Alx06 commented 9 years ago

Thanks a lot, it works now! I now have to found a way to play a background music...