
system.windows.media.MediaPlayer Maven / Gradle / Ivy
/*
* MIT License
*
* Copyright (c) 2024 MASES s.r.l.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/**************************************************************************************
*
* This code was generated from a template using JCOReflector v. 1.15.0.0
*
* Manual changes to this file may cause unexpected behavior in your application.
* Manual changes to this file will be overwritten if the code is regenerated.
*
*************************************************************************************/
package system.windows.media;
import org.mases.jcobridge.*;
import org.mases.jcobridge.netreflection.*;
import java.util.ArrayList;
// Import section
import system.windows.media.animation.Animatable;
import system.Uri;
import system.TimeSpan;
import system.windows.Duration;
import system.windows.media.MediaClock;
import system.EventHandler;
/**
* The base .NET class managing System.Windows.Media.MediaPlayer, PresentationCore, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
*
*
* .NET documentation at https://docs.microsoft.com/en-us/dotnet/api/System.Windows.Media.MediaPlayer
*
*
* Powered by JCOBridge: more info at https://www.jcobridge.com
*
* @author MASES s.r.l https://masesgroup.com
* @version 1.15.0.0
*/
public class MediaPlayer extends Animatable {
/**
* Fully assembly qualified name: PresentationCore, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
*/
public static final String assemblyFullName = "PresentationCore, Version=9.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35";
/**
* Assembly name: PresentationCore
*/
public static final String assemblyShortName = "PresentationCore";
/**
* Qualified class name: System.Windows.Media.MediaPlayer
*/
public static final String className = "System.Windows.Media.MediaPlayer";
static JCOBridge bridge = JCOBridgeInstance.getInstance(assemblyFullName);
/**
* The type managed from JCOBridge. See {@link JCType}
*/
public static JCType classType = createType();
static JCEnum enumInstance = null;
JCObject classInstance = null;
static JCType createType() {
try {
String classToCreate = className + ", "
+ (JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
if (JCOReflector.getDebug())
JCOReflector.writeLog("Creating %s", classToCreate);
JCType typeCreated = bridge.GetType(classToCreate);
if (JCOReflector.getDebug())
JCOReflector.writeLog("Created: %s",
(typeCreated != null) ? typeCreated.toString() : "Returned null value");
return typeCreated;
} catch (JCException e) {
JCOReflector.writeLog(e);
return null;
}
}
void addReference(String ref) throws Throwable {
try {
bridge.AddReference(ref);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
/**
* Internal constructor. Use with caution
*/
public MediaPlayer(java.lang.Object instance) throws Throwable {
super(instance);
if (instance instanceof JCObject) {
classInstance = (JCObject) instance;
} else
throw new Exception("Cannot manage object, it is not a JCObject");
}
public String getJCOAssemblyName() {
return assemblyFullName;
}
public String getJCOClassName() {
return className;
}
public String getJCOObjectName() {
return className + ", " + (JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
}
public java.lang.Object getJCOInstance() {
return classInstance;
}
public void setJCOInstance(JCObject instance) {
classInstance = instance;
super.setJCOInstance(classInstance);
}
public JCType getJCOType() {
return classType;
}
/**
* Try to cast the {@link IJCOBridgeReflected} instance into {@link MediaPlayer}, a cast assert is made to check if types are compatible.
* @param from {@link IJCOBridgeReflected} instance to be casted
* @return {@link MediaPlayer} instance
* @throws java.lang.Throwable in case of error during cast operation
*/
public static MediaPlayer cast(IJCOBridgeReflected from) throws Throwable {
NetType.AssertCast(classType, from);
return new MediaPlayer(from.getJCOInstance());
}
// Constructors section
public MediaPlayer() throws Throwable, system.ArgumentException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.RankException, system.ArrayTypeMismatchException, system.InvalidOperationException, system.componentmodel.InvalidEnumArgumentException, system.componentmodel.Win32Exception, system.ArgumentNullException {
try {
// add reference to assemblyName.dll file
addReference(JCOReflector.getUseFullAssemblyName() ? assemblyFullName : assemblyShortName);
setJCOInstance((JCObject)classType.NewObject());
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
// Methods section
public void Close() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException, system.globalization.CultureNotFoundException, system.UriFormatException, system.OutOfMemoryException, system.diagnostics.UnreachableException, system.componentmodel.Win32Exception, system.security.SecurityException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Invoke("Close");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void Open(Uri source) throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException, system.globalization.CultureNotFoundException, system.UriFormatException, system.security.SecurityException, system.io.IOException, system.componentmodel.InvalidEnumArgumentException, system.componentmodel.Win32Exception {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Invoke("Open", source == null ? null : source.getJCOInstance());
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void Pause() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Invoke("Pause");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void Play() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Invoke("Play");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void Stop() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Invoke("Stop");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
// Properties section
public boolean getCanPause() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (boolean)classInstance.Get("CanPause");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public boolean getHasAudio() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (boolean)classInstance.Get("HasAudio");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public boolean getHasVideo() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (boolean)classInstance.Get("HasVideo");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public boolean getIsBuffering() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (boolean)classInstance.Get("IsBuffering");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public boolean getIsMuted() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (boolean)classInstance.Get("IsMuted");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void setIsMuted(boolean IsMuted) throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Set("IsMuted", IsMuted);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public boolean getScrubbingEnabled() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (boolean)classInstance.Get("ScrubbingEnabled");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void setScrubbingEnabled(boolean ScrubbingEnabled) throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Set("ScrubbingEnabled", ScrubbingEnabled);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public double getBalance() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (double)classInstance.Get("Balance");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void setBalance(double Balance) throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Set("Balance", Balance);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public double getBufferingProgress() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (double)classInstance.Get("BufferingProgress");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public double getDownloadProgress() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (double)classInstance.Get("DownloadProgress");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public double getSpeedRatio() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (double)classInstance.Get("SpeedRatio");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void setSpeedRatio(double SpeedRatio) throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Set("SpeedRatio", SpeedRatio);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public double getVolume() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (double)classInstance.Get("Volume");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void setVolume(double Volume) throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Set("Volume", Volume);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public int getNaturalVideoHeight() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (int)classInstance.Get("NaturalVideoHeight");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public int getNaturalVideoWidth() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
return (int)classInstance.Get("NaturalVideoWidth");
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public TimeSpan getPosition() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject val = (JCObject)classInstance.Get("Position");
return new TimeSpan(val);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void setPosition(TimeSpan Position) throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Set("Position", Position == null ? null : Position.getJCOInstance());
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public Uri getSource() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject val = (JCObject)classInstance.Get("Source");
return new Uri(val);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public Duration getNaturalDuration() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject val = (JCObject)classInstance.Get("NaturalDuration");
return new Duration(val);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public MediaClock getClock() throws Throwable, system.ArgumentException, system.InvalidOperationException, system.MulticastNotSupportedException, system.PlatformNotSupportedException, system.NotSupportedException, system.ArgumentOutOfRangeException, system.ArgumentNullException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
JCObject val = (JCObject)classInstance.Get("Clock");
return new MediaClock(val);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void setClock(MediaClock Clock) throws Throwable, system.ArgumentException, system.InvalidOperationException, system.ArgumentNullException, system.IndexOutOfRangeException, system.PlatformNotSupportedException, system.ArgumentOutOfRangeException, system.MulticastNotSupportedException, system.NotSupportedException, system.globalization.CultureNotFoundException, system.UriFormatException, system.OutOfMemoryException, system.diagnostics.UnreachableException, system.componentmodel.InvalidEnumArgumentException, system.componentmodel.Win32Exception, system.security.SecurityException {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.Set("Clock", Clock == null ? null : Clock.getJCOInstance());
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
// Instance Events section
public void addBufferingEnded(EventHandler handler) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.RegisterEventListener("BufferingEnded", handler);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void removeBufferingEnded(EventHandler handler) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.UnregisterEventListener("BufferingEnded", handler);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void addBufferingStarted(EventHandler handler) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.RegisterEventListener("BufferingStarted", handler);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void removeBufferingStarted(EventHandler handler) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.UnregisterEventListener("BufferingStarted", handler);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void addMediaEnded(EventHandler handler) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.RegisterEventListener("MediaEnded", handler);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void removeMediaEnded(EventHandler handler) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.UnregisterEventListener("MediaEnded", handler);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void addMediaOpened(EventHandler handler) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.RegisterEventListener("MediaOpened", handler);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
public void removeMediaOpened(EventHandler handler) throws Throwable {
if (classInstance == null)
throw new UnsupportedOperationException("classInstance is null.");
try {
classInstance.UnregisterEventListener("MediaOpened", handler);
} catch (JCNativeException jcne) {
throw translateException(jcne);
}
}
}