How to get sound duration in AppInventor? - app-inventor

Is it possible to obtain information on the duration (in milliseconds) of a sound file used in AppInventor, or does it have to be hardcoded (for example, 90000ms for song.mp3)?
I need that information to be able to set a looping background music with the clock component. The logic is that the TimerInterval property is set dynamically to chosen sound duration - it could be 60000ms if one song is chosen, it could be something else if another song is chosen, etc.

The built in Player component does not offer that feature
but there is the Player extension, which offers a Duration property.
However to be able to loop some music you do not need the duration of the music, just set property Loop of the built in Player component to true and the music loops automatically... btw. the extension also offers a Loop event in case you need it...

Related

Multiple XAudio2 instances needed for AUDIO_STREAM_CATEGORY?

In the newer XAudio2 API's for Windows 8 and 10, an AUDIO_STREAM_CATEGORY is passed to IXAudio2::CreateMasteringVoice.
The documentation goes on to say how these should be used for different types of audio. However an IXAudio2 is only allowed one master voice. To do this is completely separate IXAudio2 instances along with all associated interfaces required, or can categories be specified elsewhere in the audio graph by some means?
Games should categorize their music streams as AudioCategory_GameMedia so that game music mutes automatically if another application plays music in the background. Music or video applications should categorize their streams as AudioCategory_Media or AudioCategory_Movie so they will take priority over AudioCategory_GameMedia streams. Game audio for in-game cinematics or cutscenes, when the audio is premixed or for creative reasons should take priority over background audio, should also be categorized as Media or Movie.
You can create more than one IXAudio2 instance in a process so each will have it's own master voice. If you want to output more than one category of audio from a process, you need to create more than one IXAudio2 instance.
Generally you can get away with just one and always use AudioCategory_GameMedia.
I know this design is a bit of a kludge but the category is set on the WASAPI output voice, which is where XAudio2 sends it's mastering voice stuff to. Any other design would have required annotating category data within the internal XAudio audio graph which would have been quite complicated to implement for not a lot of value. We choose instead to just let applications have more than one audio-graph active at once each with it's own mastering voice and therefore it's own category.
How you choose to you support the audio category feature of WASAPI is up to you, and of course the best user experience depends on what exactly your application actually does.

How to know if an audio unit of type AudioFilePlayer is playing (rendering)

I use an AUGraph and it contains some audio units of subtype kAudioUnitSubType_AudioFilePlayer.
I know we can ask if the AUGraph is running thanks to AUGraphIsRunning but I would like to know if an AudioFilePlayer audio unit is currently playing the AudioFileID i.e "produce" sound. I don't see any function like this.
Indeed the graph could "running" but the AudioFilePlayer audio unit could not produce sound (because of: end of audio file, pause, and so on...)
For the ones who are also looking for a solution, the only fix I found is to use a bool variable is_playing. Apparently, An audioFilePlayer doesn't allow to access this kind of property...

Play sound in arbitrary channel

(OSX/Cocoa)
I need to be able to take any sound (or sounds) from a collection of sound files and play it (or them) through an arbitrary sound output channel, preferably with per-sound level control and more-or-less automatic channel mixing. (meaning that multiple sounds can play simultaneously in the same channel)
The sound must be capable of being looped cleanly.
The available output channels would be in addition to the default built-in audio, added via USB audio devices. For the purposes of this question a "channel" is equivalent to a USB Audio adapter.
In other words, I need to find/write something like:
-(BOOL) [someObject playContentsOfURL: (NSURL) soundURL
viaChannel: (id) channelspec
atVolumeLevel: (double) volume
loop: (BOOL) loop
];
AVAudioPlayer is very close, but it appears to assume the use of the built-in stereo audio. I cannot figure out how to route the output to a particular output device. It loops great, however.
NSSound's playbackDeviceIdentifier does the output device routing part, but NSSound's looping is terrible. If NSSounds looping wasn't so lousy, it would be a winner.
So if you have an answer for making NSSound loop cleanly, that would answer this question very satisfactorily.
If you can specify how to provide output routing to AVAudioPlayer, that would be equally nifty.
OR, if you can point to or provide CoreAudio or other code that will accomplish this, that could work also.

Censor Plugin or Extension for VLC Media Player

I'm having an idea to create a Censor Plugin/Extension for VLC Player..
Problem Scenario :
An Adult-Scene for 1 minute in a nice movie makes it not watchable with Family.
My Solution :
Create a Plugin/Extension which does the following
Reads time positions from a file similar to subtitle files
Skip these time positions (which are adult or inappropriate) when playing
Help i needed :
I searched in Google and in videolan website, But can't find an exact solution
Are there already similar Plugins available?
Where should i start?
Please help me if you could guys.. thanks..
Same looking for having/developing Exact same solution. This might be helpful to you.
http://code.google.com/p/movie-content-editor/
A similar thing is also available on github:
https://github.com/rdp/sensible-cinema
You may also want to read this discussion thread:
https://forum.videolan.org/viewtopic.php?t=89466
finding great similar answer here
If you chop random bytes out the movie is likely not playable. The player might crash or fail to resynchronize the stream – the video might just stop. Plus, you're gonna have a hard time figuring out where the "adult" bytes are, so to speak.
If you already know where the parts are that you want to cut out, I would edit the file in any of the numerous video editors. Even Windows Movie Maker or iMovie would do the job, and those are easily available on both major OSes.
This is a requested feature for VLC. Not really anything user-friendly out there. Still, VLC offers the possibility to create playlists in a certain format that would mute or skip parts of a file. This is called XSPF. You might be able to figure out the proper format for this.
Also, there's movie-content-editor:
A VLC based editor built in python that allows users to create and use custom filter files to make movies more family friendly. Allows users to have the player automatically mute specific words or skip certain scenes based on the content of those scenes.
And sensible-cinema:
Clean Editing Movie Player allows you watch edited movies by applying delete lists (EDL's) (i.e. "mute out" or "cut out" scenes) to DVD's/files, with preliminary support for also applying them to arbitrary web/internet based players like netflix instant, hulu/hulu plus etc
See also these threads on The VideoLAN Forums:
auto skip unwanted parts of a video
Clearplay-like (content filter) module exists?

Flex 4 > spark.components.VideoPlayer > How to switch bit rate?

The VideoPlayer (possibly VideoDisplay also) component is capable of somehow automatically picking the best quality video on the list it's given. An example is here:
http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/spark/components/mediaClasses/DynamicStreamingVideoItem.html#includeExamplesSummary
I cannot find the answers to below questions.
Assuming that the server that streams recorded videos is capable of switching across same videos with different bit rates and streaming them from any point within their timelines:
Is the bandwidth test/calculation within this component only done before the video starts playing, at which point it picks the best video source and never uses the other ones? Or, does it continuously or periodically execute its bandwidth tests and does it accordingly switch between video sources during the playback?
Does it support setting the video source through code and can its automatic switching between video sources be turned off (in case I want to provide this functionality to the user in the form of some button/dropdown or similar)? I know that the preferred video source can be set, but this only means that that video source will be tested/attempted first.
What other media servers can be used with this component, besides the one provided by Adobe, to achieve automated and manual switching between different quality of same video?
Obviously, I'd like to create a player that is smart enough to automatically switch between different quality of videos, and that will support manual instructions related to which source to play - both without interrupting the playback, or at least without restarting it (minor interruptions acceptable). Also, the playback needs to be able to start at any given point within the video, after enough data has been buffered (of course), but most importantly, I want to be able to start the playback beyond what's buffered. A note or two about fast-forwarding is not going to hurt, if anyone knows anything.
Thank you for your time.

Resources