JavaFX MediaPlayer playing background music loop with small intro music - audio

I am trying to create a game using JavaFX. I had been trying to insert some background musics to the game. The musics are of compatible .mp3 files. I am currently using MediaPlayer to playback each Media. Each media file consist of the actual loop and a small (optional) intro music to the loop. How can I achieve smooth audio playback using JavaFX.
Methods I have tried:
Using the Media as one file; I try to alter the mediaPlayer.startTime, mediaPlayer.stopTime. It seems that the duration of the music is shortened when I enter the loop. However, the music restarts at the intro and ends at the wrong place. It was as if startTime didn't offset the music at all.
Using the Media as two separate files (intro and loop); I try to immediately playback the loop music as soon as the intro music is finished (using mediaPlayer.setOnEndOfMedia()). However, the transition was too slow and noticable.

After experience with other well-known game engines (e.g. Unity), I found that the files should be in .wav format as opposed to .mp3 format. This will allow the music to be looped seamlessly.

Related

How does one play higher resolution videos (4k and higher) in VLC (desktop app and Unity)?

I'm trying to get a 360 streamed video to play at its full (4k) resolution. I did do previous searching and found the below thread but it didn't answer my question.
How do I adjust the video resolution?
My end goal is to integrate this into vlc unity but I also don't see how to adjust the resolution up to 4k (or higher) for streamed videos even on the desktop app. As a test, I tried a 4k video from youtube in the VLC desktop app and couldn't see how to get it to play in 4k. The end goal is to stream from aws but I want to confirm that my stream can indeed play at 4k before continuing to try to figure out why it's playing at lower resolution within Unity. It resizes down to 1920x1080 instead of the intended 4096x2048 for my aws stream and resizes the youtube video down to 1280x720 from its 3840x2160.
I've tried messing with the advanced settings and looking at input/codecs and the best option for "preferred video resolution" is "best available" (below that is full hd). I've looked through other suggestions online and didn't see a lot to change but did change Settings-->Video-->Output to "DirectX (DirectDraw) video output. This one was just me fumbling through the desktop app, but I tried going through Media-->Open Network Stream, clicking the arrow next to play and selecting stream, choosing RTSP for destination, and then editing the resolution within the profile to be a specified width and height. None of the above changed the resolution of the video.
TL;DR - How can I play a streamed video at higher resolutions (4k and up) in the VLC desktop app and in VLC Unity?
Edit - adding requested code snippets. This just modifies the UseRenderingPlugin file from the VLC unity asset.
Also, similar to what was getting discussed in the comments, when I play the video locally instead of streaming, it plays at the full resolution of the video.
Within Awake() I set the material to the 4096x2048 one mentioned for the skybox
RenderSettings.skybox = material4k;
And then in Update here is the relevant segment
var texptr = _mediaPlayer.GetTexture(out bool updated);
            if (updated && texptr != IntPtr.Zero)
            {
                Debug.Log("Creating texture ");
                tex = Texture2D.CreateExternalTexture((int)width,
                    (int)height,
                    TextureFormat.RGBA32,
                    false,
                    true,
                    texptr);
                RenderSettings.skybox.mainTexture = tex;
                }

medialement.js not working for my hls on iphone

Here is my m3u8 file:
cat 8.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:YES
#EXT-X-MEDIA-SEQUENCE:1131
#EXT-X-TARGETDURATION:5
#EXTINF:4.950, no desc
1545049888215.ts
#EXTINF:4.950, no desc
1545049893218.ts
I serve it at as static file at http://104.248.205.68:31339/8.m3u8
I use mediaelemnts.js to run this hls video: jsfiddle
html:
<video width="240" height="160"
id="player1" src="http://104.248.205.68:31339/8.m3u8"
controls="controls" autoplay preload="auto" muted ></video>
js:
$('video').mediaelementplayer({});
It works fine on chrome mac os desktop. But not working on iphone 8+ (safari and chrome). No errors in the console. Video just not played, black screen. In the fullscreen mode of video - the same.
At the same time, if I find a random m3u8 on the internet and use mediaelemnts.js to play it, it works well on the iPhone (at least in fullscreen mode) jsfiddle 2.
So I guess something wrong with my m3u8 file since other m3u8s are runnable on the iPhone.
If I open network tab while loading the problem page on Iphone, I see it's downloading the files but not showing video for some reason.
Update
I checked on android: galaxy s5 and galaxy s9+ in chrome: both works.
Update 2
Zip archive with ts files and m3u8: http://104.248.205.68:31339/8.m3u8.zip
When inspecting the media files [1] it can be found that the PMT (Program Map Table) signals that there is audio in the stream, but there are actually no TS packets for audio (i.e. no audio data) present.
It looks like the player waits for the audio TS packets in order to build a common buffer for both, audio and video, and only then start playback. Since the stream lacks audio data that never happens. To back that up, you can use ffmpeg to remove the audio track from the media segments using the below command and find that playback would work once you do this.
ffmpeg -i 1545049893218.ts -an -vcodec copy 1545049893218-v.ts
Further, the reason this problem only manifests in Safari and Chrome on iOS is that in those cases mediaelement.js is using the browser's native capabilities to play HLS, instead of a JavaScript player (like hls.js) which is used on other platforms (e.g. Chrome on desktop) and is more tolerant to such problem cases.
[1] E.g. using http://thumb.co.il/ or ffprobe
EDIT:
While the above may be sufficient to make it work on older Apple mobile devices - I tested on iPhone 6 iOS10 - newer devices seem to be more restrictive. The official HLS Authoring Spec states
8.11. You MUST provide at least 6 segments in a live/linear playlist.
which does not seem to be a hard requirement on some iOS versions. However, to ensure it to be working on all versions these requirements should be met.
I did a quick test on iPhone X with iOS12 and found it would play if at least 3 segments are provided in the playlist by just duplicating the last segment entry.

Extract image frame from video in c#

I trying to create media player in window form application us C#. I want to get thumbnails of video file in order to show them in the playing list, Can any body help me to figure out the code or refer me some links. i am really stuck at this point

Monotouch: Play movie without interrupting audio of other apps e.g. iPod

I have a silent movie (No sound at all in that clip) which acts as a background movie for my view.
When I play music with iPod and then open my app the iPod music stops.
I don´t want my movie to interrupt the iPod Audio. I´ve read that UseApplicationAudioSession is deprecated but how do I realize this now?
Thank you for your help!
EDIT: And because I add an image onto the MovieplayerViewController I can not use AVPlayer.
PS: Other threads I´ve found here do mention the deprecated UseApplicationAudioSession solution thats why I opened a new question.
Thanks :)
Here is my solution:
AVAudioSession audioSession = AVAudioSession.SharedInstance();
NSError audioSessionError = new NSError();
audioSession.SetCategory(new NSString("AVAudioSessionCategoryAmbient"), out audioSessionError);

Play audios compressed with G729 in J2ME

I want to play an audio compressed with G729. How can I handle codes in J2ME player?
Player p = Manager.createPlayer(url);
p.realize();
where and what I put here to mention about G729.? Any explanation with a sample code please.
I looked here as well.but couldn't find a good solution.

Resources