Baseflow / XamarinMediaManager

Cross platform Xamarin plugin to play and control Audio and Video
https://baseflow.com
MIT License
769 stars 306 forks source link

How could I add multiple players to play videos at the same time? #211

Open hs79hs opened 7 years ago

hs79hs commented 7 years ago

Hi, related to #100, could someone instruct me how to play multiple videos at the same time using MediaManager.Forms? I tried to add 4 in Xaml like this,

<Grid VerticalOptions="FillAndExpand" RowSpacing="0" ColumnSpacing="0">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>

        <forms:VideoView x:Name="videoview1" Grid.Row="0" Grid.Column="0" Source="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" />
        <forms:VideoView x:Name="videoview2" Grid.Row="0" Grid.Column="1" Source="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" />
        <forms:VideoView x:Name="videoview3" Grid.Row="1" Grid.Column="0" Source="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" />
        <forms:VideoView x:Name="videoview4" Grid.Row="1" Grid.Column="1" Source="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" />
    </Grid>

And in .xaml.cs, I have code like this,

private IPlaybackController PlaybackController => CrossMediaManager.Current.PlaybackController;
...
PlaybackController.Play();

But while running, only the last one is playing. Other three show black screen. Is it possible to achieve this?

Is it because that I only defined one PlaybackController? But I tried to define more than one PlaybackController, it didn't work. Is there some example code for this?

Thank you very much. @martijn00 @SimonSimCity @modplug

The reason I want to do this is that, I want to monitor and play rtsp streams from several IP cameras at the same time. I've tested, it's okay to play a rtsp stream from a camera.

Charles808 commented 6 years ago

Hi ! In my case , the event listener for PlayingChanged, MediaFinished get called from other page. I think it is because the CrossMediaManager.Current.PlaybackController is Singleton.

Do you solve this yet ? I also want to create separate instance and add their each own event listener.

Charles808 commented 6 years ago

In the end I used static class to save the current page name, it is used to filter which part of event listener will be executed depending on which page is being opened. For the multiple instance still not know yet, and for now I don't need it.

ligeirow commented 2 years ago

rtsp

this run rtsp with login/password? i try but dont connect