unosquare / ffmediaelement

FFME: The Advanced WPF MediaElement (based on FFmpeg)
https://unosquare.github.io/ffmediaelement/
Other
1.17k stars 240 forks source link

Move/swap two MediaElement controls while playing video between two host controls <ContentControl> tag #530

Closed manity42 closed 3 years ago

manity42 commented 3 years ago

*Move/swap two MediaElement controls while playing video between two host controls tag. I am trying to swap two media element controls between two different hosts where each media element is assigned to the hosts ContentControl. I want to swap them while they are both playing a file and to keep playing the file after the swap. But i can get the swap to work only on one player. The second player resets to an un initialised state.

I believe the problem is that the player assigned to a temp holding variable, is removed from the applications visual tree and hence is reset.

I have tried creating a second "ContentControl> inside a host to use as a temp store of the mediaelement but that does not work either.

Can anyone suggest a way i can achieve this swap result between two whilst keeping the two media elements playing videos, and keeping the current state of each player.

I have tried up upload a sample project but with the FFMPEG runtimes it exceeds the 10meg limit even under high zip compression.

I hope the code sample below illustrates what im doing.

*

Issue Categories

Version Information

Steps to Reproduce

Expected Results

Sample Code

I have tried up upload a sample project but with the FFMPEG runtimes it exceeds the 10meg limit even under high zip compression.

I hope this code sample illustrates what im doing

Unosquare.FFME.MediaElement tempMe = MediaHost1.MediaElement; MediaHost1.MediaElement = MediaHost2.MediaElement; MediaHost2.MediaElement = tempMe;

and in the host to assign the media element

public Unosquare.FFME.MediaElement MediaElement { get => _MediaElement; set { _MediaElement = value; this.hostContent.Content = _MediaElement;

            RaisePropertyChanged(nameof(MediaElement));
        }

    }
mariodivece commented 3 years ago

Have you tried setting element1.UnloadedBehavior = MediaPlaybackState.Manual; on both elements and made sure Library.EnableWpfMultiThreadedVideo = false; Let me know if that solves the issue. Make sure you MANUALLY dispose the mediaelements after using them. Otherwise you will end up with a memory leak.

manity42 commented 3 years ago

I have tried what you suggested under version 4.2.330.0 and it made no difference, it functions in the same way, I see just now you have release a new version. I will test it again under the new version.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Ocimandias commented 3 years ago

Dear manity42,

We worked on that and found a way that solves our requirements keeping a list of FFME controls on memory and setting MediPlayerBrush property of each to the background of any visual control. We use to work with borders BrdVideoBrushMain.Background = oMediPlayer.MediPlayerBrush I hope that this helps Best