Skip to content

Commit

Permalink
Add working browser connection
Browse files Browse the repository at this point in the history
  • Loading branch information
martijn00 committed Jul 19, 2018
1 parent cffa78d commit c76564e
Show file tree
Hide file tree
Showing 23 changed files with 482 additions and 229 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,6 @@ csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true

# Braces after if
csharp_prefer_braces = false
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,7 @@ artifacts/
*.binlog

#linting
.sonarqube/
.sonarqube/

# dotnet tools
.store/
26 changes: 21 additions & 5 deletions Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
<PackageLicenseUrl>https://opensource.org/licenses/MIT</PackageLicenseUrl>
<PackageProjectUrl>https://github.com/martijn00/XamarinMediaManager</PackageProjectUrl>
<PackageIconUrl>https://github.com/martijn00/XamarinMediaManager/blob/master/icon_MediaManager.png</PackageIconUrl>
<Owners>Martijn van Dijk</Owners>
<Authors>Martijn van Dijk</Authors>
<Owners>Martijn van Dijk</Owners>
<PackageTags>xamarin, android, plugin, MediaManager, media, audio, video</PackageTags>
<PackageReleaseNotes>https://github.com/martijn00/XamarinMediaManager</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<RepositoryUrl>https://github.com/martijn00/XamarinMediaManager</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<Product>$(AssemblyName) ($(TargetFramework))</Product>
Expand All @@ -22,16 +23,31 @@

<Platform>AnyCPU</Platform>
<DebugType>full</DebugType>
<IsTestProject>$(MSBuildProjectName.Contains('Tests'))</IsTestProject>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<EmbedUntrackedSources>true</EmbedUntrackedSources>

<IsTestProject>$(MSBuildProjectName.Contains('UnitTest'))</IsTestProject>
<IsLibraryProject>$(MSBuildProjectName.Contains('MediaManager'))</IsLibraryProject>
</PropertyGroup>

<ItemGroup Condition="'$(IsLibraryProject)' == 'true'">
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.5.4" PrivateAssets="All" />
<PackageReference Include="Microsoft.CSharp" Version="4.4.1" PrivateAssets="All" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup Condition="'$(IsTestProject)' != 'true' and '$(SourceLinkEnabled)' != 'false' and '$(IsLibraryProject)' == 'true'">
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.1" PrivateAssets="All" />
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.8.3" PrivateAssets="All" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63102-01" PrivateAssets="All"/>
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<!--<TargetsToBuild>All</TargetsToBuild>-->
<TargetsToBuild>Android</TargetsToBuild>
<!--<TargetsToBuild>Uap</TargetsToBuild>-->
<!--<TargetsToBuild>iOS</TargetsToBuild>-->
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' != 'Debug' ">
<TargetsToBuild>All</TargetsToBuild>
</PropertyGroup>

</Project>
4 changes: 0 additions & 4 deletions Directory.build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,4 @@
<PropertyGroup Condition="$(TargetFramework.StartsWith('tizen'))">
<DefineConstants>$(DefineConstants);TIZEN</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('uap'))">
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform" Version="6.0.8" />
</ItemGroup>
</Project>
33 changes: 15 additions & 18 deletions MediaManager.Forms/MediaManager.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,55 +29,52 @@
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('uap')) ">
<Compile Include="Platforms\Windows-common\**\*.cs" />
<Compile Include="Platforms\Windows\**\*.cs" />
<Compile Condition=" '$(OS)' == 'Windows_NT' " Include="Platforms\Uap\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.iOS')) ">
<Compile Include="Platforms\Apple-common\**\*.cs" />
<Compile Include="Platforms\Ios\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<Compile Include="Platforms\Xamarin\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.Mac')) ">
<Compile Include="Platforms\Apple-common\**\*.cs" />
<Compile Include="Platforms\Mac\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<Compile Include="Platforms\Xamarin\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.TVOS')) ">
<Compile Include="Platforms\Apple-common\**\*.cs" />
<Compile Include="Platforms\Tvos\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<Compile Include="Platforms\Xamarin\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.WatchOS')) ">
<Compile Include="Platforms\Apple-common\**\*.cs" />
<Compile Include="Platforms\Watchos\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<Compile Include="Platforms\Xamarin\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
<Compile Include="Platforms\Android\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<Compile Include="Platforms\Xamarin\**\*.cs" />
<AndroidResource Include="Resources\**\*.xml" SubType="Designer" Generator="MSBuild:UpdateAndroidResources" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Core" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Dash" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Hls" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.SmoothStreaming" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.UI" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Cast" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Leanback" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.MediaSession" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Core" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Dash" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Hls" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.SmoothStreaming" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.UI" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Cast" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Leanback" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.MediaSession" Version="2.8.4" />
<PackageReference Include="Xamarin.Build.Download" Version="0.4.11" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('tizen')) ">
<Compile Include="Platforms\Tizen\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<PackageReference Include="Tizen.NET" Version="4.0.0">
<ExcludeAssets>Runtime</ExcludeAssets>
</PackageReference>
<Compile Include="Platforms\Xamarin\**\*.cs" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion MediaManager/IMediaPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public interface IMediaPlayer
// <summary>
/// Adds MediaFile to the Queue and starts playing
/// </summary>
Task Play(IMediaItem mediaItem);
Task Play(string Url);

// <summary>
/// Starts playing
Expand Down
8 changes: 6 additions & 2 deletions MediaManager/Media/IMediaQueue.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
namespace MediaManager.Media
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;

namespace MediaManager.Media
{
public interface IMediaQueue
public interface IMediaQueue : IList<IMediaItem>, INotifyCollectionChanged, INotifyPropertyChanged
{
}
}
3 changes: 2 additions & 1 deletion MediaManager/Media/MediaQueue.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;

namespace MediaManager.Media
{
public class MediaQueue : IMediaQueue
public class MediaQueue : ObservableCollection<IMediaItem>, IMediaQueue
{
}
}
46 changes: 26 additions & 20 deletions MediaManager/MediaManager.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<Project Sdk="MSBuild.Sdk.Extras">
<PropertyGroup>
<PropertyGroup Condition=" '$(TargetsToBuild)' == 'All' ">
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">netstandard2.0;net461;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;MonoAndroid81;tizen40;uap10.0.16299</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0;net461;Xamarin.iOS10;Xamarin.Mac20;Xamarin.TVOS10;MonoAndroid81;tizen40</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Condition=" '$(TargetsToBuild)' != 'All' ">
<TargetFrameworks Condition=" '$(TargetsToBuild)' == 'Android' ">netstandard2.0;MonoAndroid81;</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetsToBuild)' == 'Uap' ">netstandard2.0;uap10.0.16299</TargetFrameworks>
<TargetFrameworks Condition=" '$(TargetsToBuild)' == 'iOS' ">netstandard2.0;Xamarin.iOS10</TargetFrameworks>
</PropertyGroup>

<PropertyGroup>
<AssemblyName>MediaManager</AssemblyName>
<RootNamespace>MediaManager</RootNamespace>
<PackageId>MediaManager</PackageId>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Platforms\**\*.cs" />
<None Include="Platforms\**\*.cs" />
Expand All @@ -29,55 +38,52 @@
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('uap')) ">
<Compile Include="Platforms\Windows-common\**\*.cs" />
<Compile Include="Platforms\Windows\**\*.cs" />
<Compile Condition=" '$(OS)' == 'Windows_NT' " Include="Platforms\Uap\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.iOS')) ">
<Compile Include="Platforms\Apple-common\**\*.cs" />
<Compile Include="Platforms\Ios\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<Compile Include="Platforms\Xamarin\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.Mac')) ">
<Compile Include="Platforms\Apple-common\**\*.cs" />
<Compile Include="Platforms\Mac\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<Compile Include="Platforms\Xamarin\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.TVOS')) ">
<Compile Include="Platforms\Apple-common\**\*.cs" />
<Compile Include="Platforms\Tvos\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<Compile Include="Platforms\Xamarin\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.WatchOS')) ">
<Compile Include="Platforms\Apple-common\**\*.cs" />
<Compile Include="Platforms\Watchos\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<Compile Include="Platforms\Xamarin\**\*.cs" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('MonoAndroid')) ">
<Compile Include="Platforms\Android\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<Compile Include="Platforms\Xamarin\**\*.cs" />
<AndroidResource Include="Resources\**\*.xml" SubType="Designer" Generator="MSBuild:UpdateAndroidResources" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Core" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Dash" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Hls" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.SmoothStreaming" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.UI" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Cast" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Leanback" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.MediaSession" Version="2.8.3" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Core" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Dash" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Hls" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.SmoothStreaming" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.UI" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Cast" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.Leanback" Version="2.8.4" />
<PackageReference Include="Xam.Plugins.Android.ExoPlayer.MediaSession" Version="2.8.4" />
<PackageReference Include="Xamarin.Build.Download" Version="0.4.11" />
</ItemGroup>

<ItemGroup Condition=" $(TargetFramework.StartsWith('tizen')) ">
<Compile Include="Platforms\Tizen\**\*.cs" />
<Compile Include="Platforms\Xamarin-common\**\*.cs" />
<PackageReference Include="Tizen.NET" Version="4.0.0">
<ExcludeAssets>Runtime</ExcludeAssets>
</PackageReference>
<Compile Include="Platforms\Xamarin\**\*.cs" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion MediaManager/MediaManagerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace MediaManager
{
public abstract class MediaManagerBase : IMediaManager
{
public abstract IAudioPlayer AudioPlayer { get; set; }
//public abstract IAudioPlayer AudioPlayer { get; set; }
public abstract IVideoPlayer VideoPlayer { get; set; }
public abstract INotificationManager NotificationManager { get; set; }

Expand Down
10 changes: 7 additions & 3 deletions MediaManager/MediaManagerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MediaManager.Media;

Expand All @@ -8,13 +9,16 @@ public static class MediaManagerExtensions
{
public static Task Play(this IMediaManager mediaManager, IMediaItem item)
{
return mediaManager.PlaybackManager.CurrentMediaPlayer.Play(item);
return mediaManager.PlaybackManager.Play(item);
}

public static Task Play(this IMediaManager mediaManager, IEnumerable<IMediaItem> items)
{
mediaManager.MediaQueue.Add(items);
return mediaManager.PlaybackManager.CurrentMediaPlayer.Play(item);
foreach (var item in items)
{
mediaManager.MediaQueue.Add(item);
}
return mediaManager.PlaybackManager.Play(items.First());
}
}
}
6 changes: 3 additions & 3 deletions MediaManager/Platforms/Android/AudioPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public Task Pause()
throw new NotImplementedException();
}

public Task Play(IMediaItem item)
public Task Play(string Url)
{
var mediaUrl = item.MetadataMediaUri;
var mediaUri = Android.Net.Uri.Parse(mediaUrl);
//var mediaUrl = item.MetadataMediaUri;
var mediaUri = Android.Net.Uri.Parse(Url);

var userAgent = Util.GetUserAgent(context, "ExoPlayerDemo");
var defaultHttpDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent);
Expand Down
Loading

0 comments on commit c76564e

Please sign in to comment.