mirror of
https://github.com/devon22/obsidian-mediaviewer.git
synced 2026-07-22 11:50:28 +00:00
2.0.8
This commit is contained in:
parent
c6224ae76e
commit
83db402a5a
5 changed files with 92 additions and 10 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "mediaviewer",
|
||||
"name": "Media Viewer",
|
||||
"version": "2.0.7",
|
||||
"version": "2.0.8",
|
||||
"minAppVersion": "1.1.0",
|
||||
"description": "View and manage media files within your notes.",
|
||||
"author": "Devon22",
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "mediaviewer",
|
||||
"version": "2.0.7",
|
||||
"version": "2.0.8",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mediaviewer",
|
||||
"version": "2.0.7",
|
||||
"version": "2.0.8",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@esbuild/linux-x64": "0.17.3",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "mediaviewer",
|
||||
"version": "2.0.7",
|
||||
"version": "2.0.8",
|
||||
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -314,6 +314,24 @@ export class GalleryBlock {
|
|||
path: file.path,
|
||||
title: currentTitle,
|
||||
linkUrl: currentLinkUrl,
|
||||
thumbnail: currentThumbnail,
|
||||
originalBlock: originalBlock,
|
||||
loc: { start: tempStartLine, end: i }
|
||||
});
|
||||
}
|
||||
}
|
||||
} else if (isImage && currentThumbnail) {
|
||||
// 處理帶有 img 參數的影片連結
|
||||
if (file) {
|
||||
const extension = file.extension.toLowerCase();
|
||||
if (extension.match(/^(mp4|mkv|mov|webm|mp3|m4a|flac|ogg|wav|3gp)$/)) {
|
||||
items.push({
|
||||
type: 'video',
|
||||
url: this.app.vault.getResourcePath(file),
|
||||
path: file.path,
|
||||
title: currentTitle,
|
||||
linkUrl: currentLinkUrl,
|
||||
thumbnail: currentThumbnail,
|
||||
originalBlock: originalBlock,
|
||||
loc: { start: tempStartLine, end: i }
|
||||
});
|
||||
|
|
@ -373,6 +391,7 @@ export class GalleryBlock {
|
|||
path: text || fileByPath.path,
|
||||
title: currentTitle,
|
||||
linkUrl: currentLinkUrl,
|
||||
thumbnail: currentThumbnail,
|
||||
originalBlock: originalBlock,
|
||||
loc: { start: tempStartLine, end: i }
|
||||
});
|
||||
|
|
@ -385,6 +404,7 @@ export class GalleryBlock {
|
|||
path: text || file.path,
|
||||
title: currentTitle,
|
||||
linkUrl: currentLinkUrl,
|
||||
thumbnail: currentThumbnail,
|
||||
originalBlock: originalBlock,
|
||||
loc: { start: tempStartLine, end: i }
|
||||
});
|
||||
|
|
@ -398,10 +418,63 @@ export class GalleryBlock {
|
|||
path: text,
|
||||
title: currentTitle,
|
||||
linkUrl: currentLinkUrl,
|
||||
thumbnail: currentThumbnail,
|
||||
originalBlock: originalBlock,
|
||||
loc: { start: tempStartLine, end: i }
|
||||
});
|
||||
}
|
||||
} else if (isImage && currentThumbnail) {
|
||||
// 處理帶有 img 參數的影片連結
|
||||
if (!url.startsWith('http://') && !url.startsWith('https://')) {
|
||||
const file = this.app.metadataCache.getFirstLinkpathDest(url, '');
|
||||
if (!file) {
|
||||
const fileByPath = this.app.vault.getAbstractFileByPath(url);
|
||||
if (fileByPath && fileByPath instanceof TFile) {
|
||||
const extension = fileByPath.extension.toLowerCase();
|
||||
if (extension.match(/\.(mp4|mkv|mov|webm|mp3|m4a|flac|ogg|wav|3gp)$/)) {
|
||||
items.push({
|
||||
type: 'video',
|
||||
url: this.app.vault.getResourcePath(fileByPath),
|
||||
path: text || fileByPath.path,
|
||||
title: currentTitle,
|
||||
linkUrl: currentLinkUrl,
|
||||
thumbnail: currentThumbnail,
|
||||
originalBlock: originalBlock,
|
||||
loc: { start: tempStartLine, end: i }
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const extension = file.extension.toLowerCase();
|
||||
if (extension.match(/^(mp4|mkv|mov|webm|mp3|m4a|flac|ogg|wav|3gp)$/)) {
|
||||
items.push({
|
||||
type: 'video',
|
||||
url: this.app.vault.getResourcePath(file),
|
||||
path: text || file.path,
|
||||
title: currentTitle,
|
||||
linkUrl: currentLinkUrl,
|
||||
thumbnail: currentThumbnail,
|
||||
originalBlock: originalBlock,
|
||||
loc: { start: tempStartLine, end: i }
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const urlForTypeCheck = url.split(' "')[0].split('?')[0].toLowerCase();
|
||||
const isVideoFile = urlForTypeCheck.match(/\.(mp4|mkv|mov|webm|mp3|m4a|flac|ogg|wav|3gp)$/);
|
||||
if (isVideoFile) {
|
||||
items.push({
|
||||
type: 'video',
|
||||
url: url.split(' "')[0],
|
||||
path: text,
|
||||
title: currentTitle,
|
||||
linkUrl: currentLinkUrl,
|
||||
thumbnail: currentThumbnail,
|
||||
originalBlock: originalBlock,
|
||||
loc: { start: tempStartLine, end: i }
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 處理一般連結
|
||||
items.push({
|
||||
|
|
@ -1080,12 +1153,21 @@ export class GalleryBlock {
|
|||
if (media.path && media.url) {
|
||||
// 處理影片檔案
|
||||
if (media.path.toLowerCase().match(/\.(mp4|mkv|mov|webm)$/)) {
|
||||
const video = document.createElement('video') as HTMLVideoElement;
|
||||
if (!Platform.isAndroidApp) {
|
||||
video.src = media.url;
|
||||
// 如果有自訂縮圖,使用縮圖顯示
|
||||
if (media.thumbnail) {
|
||||
const img = document.createElement('img') as HTMLImageElement;
|
||||
img.src = media.thumbnail;
|
||||
img.alt = media.path || '';
|
||||
img.className = 'mvgb-video-thumbnail';
|
||||
container.appendChild(img);
|
||||
} else {
|
||||
const video = document.createElement('video') as HTMLVideoElement;
|
||||
if (!Platform.isAndroidApp) {
|
||||
video.src = media.url;
|
||||
}
|
||||
video.style.pointerEvents = 'none';
|
||||
container.appendChild(video);
|
||||
}
|
||||
video.style.pointerEvents = 'none';
|
||||
container.appendChild(video);
|
||||
|
||||
if (!Platform.isAndroidApp) {
|
||||
const videoIcon = document.createElement('div');
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"2.0.7": "1.1.0"
|
||||
"2.0.8": "1.1.0"
|
||||
}
|
||||
Loading…
Reference in a new issue